The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The
Woz Wonderbook
A compendium of notes, diagrams, articles, instructions and code
that describes the Apple ][ computer and how to program it.
AUTHOR
Steve Wozniak ( www.woz.org )
DOCUMENT DATES OF RECORD
September 20, 1977 - November 15, 1977
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0001 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0002 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
Introduction
A compendium of notes, diagrams, articles, instructions and code that
describes the Apple ][ computer and how to program it.
What is the Woz Wonderbook?
The Woz Wonderbook was pulled together from Steve Wozniak's file drawers in
the Summer and Fall of 1977 and served as the key reference describing the
Apple ][ for Apple's own employees. The Wonderbook served as a primary source
for the first real Apple ][ manual, the Red Book, published in January 1978.
Apple ] [ sales were increasing since its introduction at the West Coast
Computer Fair in April 1977 and Woz and a team at Apple used the Wonderbook
to bridge the gap in documentation as Apple and Steve Jobs realized they had
to create a more professional product and manuals. There was only one Woz
Wonderbook in the Apple library. The Woz Wonderbook at the DigiBarn was one
of only a few copies made of this master by Apple employees at the time for
internal use.
Facts about the Woz Wonderbook
Author :
Steve Wozniak (www.woz.org <http://www.woz.org/)
Document dates of record:
September 20, 1977-November 15. 1977
Owner :
DigiBarn Computer Museum (www.digibarn.com).
Curator Bruce Damer (http://www.damer.com/).
DigiBarn's pages on the Wonderbook including this version can be found at:
http : //www. di gi barn . com/ col lections /books /woz -wonder book/
This Wonderbook was discarded by Apple Computer Inc. (http://www.apple.com/)
and recovered by Bill Goldberg who later donated it to the DigiBarn Computer
Museum .
This Wonderbook was scanned and resurrected in October 2004 into PDF format
by David T Craig (shirlgato@cyberfflesa.com).
This digital rendition of the Woz Wonderbook is available for non-commercial,
educational and research purposes with the requirement to provide attribution
and share-alike under the Creative Commons license provided on page 5.
All other uses require the agreement of the DigiBarn Computer Museum (contact
through www.digibarn.com).
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0003 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
Property Statement
This Woz Wonderbook is the property of the DigiBarn Computer Museum which is
offering it under the following Creative Commons License found on page 5.
Under the terms of this license you must credit the DigiBarn Computer Museum,
Steve Wozniak and Apple Computer, Inc. if whole or part of this Wonderbook is
used for non commercial / educational or research purposes. All other uses
require the agreement of the DigiBarn Computer Museum (contact through
www . di gi barn . com) .
We would like to acknowledge Bill Goldberg for providing us this copy of the
Woz Wonderbook.
The author of the Woz Wonderbook is Steve Wozniak.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 0004 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
©creative
commons
C C) M M C) N S D i: V. D
Creative Commons
Attribution - Non Commercial - Share Alike 1.0
You are free:
* to copy, distribute, display, and perform the work
* to make derivative works
Under the following conditions:
Attribution. You must give the original author credit.
Noncommercial. You may not use this work for commercial purposes.
Share Alike. If you alter, transform, or build upon this work, you may
distribute the resulting work only under a license identical to this
one .
* For any reuse or distribution, you must make clear to others the
license terms of this work.
* Any of these conditions can be waived if you get permission from
the copyright holder.
Your fair use and other rights are in no way affected by the above.
This is a human- readable summary of the Legal Code.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0005 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
Disclaimer
The Commons Deed is not a license. It is simply a handy reference for
understanding the Legal Code (the full license) - it is a human-
readable expression of some of its key terms. Think of it as the user-
friendly interface to the Legal Code beneath. This Deed itself has no
legal value, and its contents do not appear in the actual license.
Creative Commons is not a law firm and does not provide legal services.
Distributing of, displaying of, or linking to this Commons Deed does
not create an attorney-client relationship.
For the full legal code for this license see:
http://creati vecommons .org/li censes /by- nc-s a/2 .0/
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0006 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
Table of Contents
Auto Repeat for Apple-II Monitor Commands
20 September 1977
Use of the Apple-II Mi ni -Asssembler
Apple-II Pointers and Mailboxes
Apple-II 2716 EPROM Adaptation ('DO' and 'D8' Sockets)
18 November 1977
Using Apple-II Color Graphics
Adding Colors to Apple-II Hi -Res
Apple-II Disassembler Article (Apple-II MONITOR ROM)
Apple-II Cassette Article
Apple-II Floating Point Package
Apple-II Sweet-IG -- The 6502 Dream Machine
Apple-II 6502 Code Relocation Program
14 November 1977
Apple-II Renumbering and Appending BASIC Programs
15 November 1977
References
03 November 2004
Bill Goldberg Interview
19 April 2004
Credi ts
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0007 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0008 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Auto Repeat
for
Apple-II Monitor Commands
20 September 1977
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 0009 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0010 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
9/20/77
Woz
AUrO RLPEAT FOR APPLE -II MONITOR CO!''„'-ANDS
It is occasionally desirable to autDmatically repeat a MONITOR corunand
or c.:-;iirind sequence on the APPLE II ca-nputer. For exerriple, flaky (inter-
mittently bad) RAM bits in the $800 - $FFF address range ($ stands for hex)
trgy Lg detected by verifying those locations with tliemsel ves using the MON-
ITOR verify co'.n.-ind:
*800<8U0.FFF\V(no blanks) (A is car ret)
E:-cause this problem fs intermittent, multiple verifications may be
r,r-ces£ary before the problem is detected. Typing the verify command over and
over is a tedious chore which may not even catch the bug, particularly since the
RAMS are liot fully exercised while the user is typing.
The APPLE - II MONITOR coninand input buffer begins at location $200 and
is scanned from begiiining to end after the user finishes the line by typing
a carriage return. An index to the next executable character of the buffer
resides in location $34 while any function is being executed. By adding
the coriiir.and '34:0' to the end of a MONITOR command sequence the user causes
scanning to resume at the beginning. Because the '34:0' comnand leaves
the MONITOR in 'store' more, an 'N' command should begin the line. The
following is an example of a contiiand sequence which verifies locations
$800 - $FFF with themselves, autom,atically repeating.
*N800<800.FFFV 34:0 HA is blank)
(Note that the trailing blank is necessary for this feature to
work properly)
M'jltiple connand sequences accepted by the Apple II MONITOR may also
be autoiiiati cal ly repeated. For example, the following command sequence clears
all bits in the address range $400 - $5FF, verifies these locations with
tr.eriselvGS , sets them all to ones, verifies them again, and repeats:
*N;00:0 ^ N401<400.5FEM 400<400.5FFV 400:FF ti N401 <400. 5FEM
400--400.5FFV 34:0
)4 is npcessary blank
is car return
Because this example uses screen memory locations, it is observable on
the display. The repeating coiTuiand may be halted by hitting RESET. Since the
cursor is only generated for keyboard entry, it will disappear while the ex-
ample repeats.
Distributed under the Creative Commons License on page 5
Page 0011 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0012 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Use of the
Apple-II Mi ni -Asssembler
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 001 3 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0014 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The following section covers use of the Apple II mini-
assembler only. It is not a course 'in assembly language
programming. For a reference on programming the 6502 micro-
processor, refer to the HOS Technology Programming manual.
The following section assumes the user has a working know-
ledge of 6502 programming and mnemonics.
The Apple II mi n i -a s s amb 1 e r is a programming aid ai'med
at reducing the amount of time required to convert a hand-
written program to object code. The mi ni -assembl er i s
basically a look-up table for opcodes. Wit it, you can type
mnemonics with their absolute addresses, and the assembler
will convert it to the correct object code and store it in
memory .
Typing "F666G" will put the user in mini - assembl er mode.
While in this mode, any line typed in will be interpreted as
an assembly language instruction, assembled, and stored In
binary form unless the first character on the command line
is a "$".
If it is, the remainder of the line will be Interpreted
as a normal monitor command, executed , ^and control returned
to assembler mode. To get out of the assembler mode, reset must be
pushed.
, If the first character on the line is blank, the assem-
bled instruction will be stored starting at the address im-
mediately following the previously assembled instruction.
If the first character is nonblank (and not "$"), the line
is ass^umed to contain an assembly language instruction pre-
ceded by the instruction addr'ess (a hex number followed by
a ":")• In either case, the ; i ns t rue t i on will be retyped
over the line just entered in disassembler format to provide
a visual check of what has seen assemble'. The counter that
Distributed under the Creative Commons License on page 5
Page 0015 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
keeps track of where the next instruction will be stored is
the pseudo PC (Program Counter) and it can be changed by many
monitor commands (eg.'L', 'T ..,)• Therefore, it is advisable
to use the explicit instruction address mode after every monitor
command and, of'course, when the Tiny assembler is first'
entered .
Errors (unrecognized mnemonic, illegal format, etc.) are.
signalled by a "beep" and a carrot ("-") will be printed be-
neath the last character read frono the input line by the mini-
assembl er.
The mnemonics and formats accepted by the mini assembler
are the same as those listed by the 6502 Programmers Manual,
with the following exceptions and differences:
1. All imbedded blanks are ignored, except inside
addresses ,
2. All addresses typed in are assumed to be in hex
(rather than decimal or symbolic). A preceding "$"
(indicating hex rather than decimal or symbolic) is
therefore optional, except that it should not pre-
cede the instruction address).
3. Instructions that operate on the accumulator have
a blank operand field instead of "A".
4. When entering a branch instruction, following the
branch mnemonic should be the target of the branch.
If the destination address is not known at the time
the instruction is entered, simply enter an address
that is in the neighborhood, and later re-enter the
branch instruction with the correct target address.
NOTE : If a branch target is specified that is out of
range, the mi ni -assembl er will flag the address as
being in error.
Distributed under the Creative Commons License on page 5
Page 0016 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
5. The operand field of an instr-uction can only be
follcv/ed by a cominent field, which starts with a semi-
colon (";"). Obviously, the Tiny assembler ignores
the field and in fact will type over it when the line
is typed over in disassembler format. This "feature"
is included only to be compatible with future up-
grades including input sources other than the key-
board.
6, Any page zero references will generate page zero
instruction formats if such a mode exists. There
is no way to force a page zero address to be two
bytes, even if the address has leading zeroes.
In general, to specify an addressing type, simply
enter it as it would be listed in the disassembly. For In-
formation on the disassembler, see the monitor section.
Distributed under the Creative Commons License on page 5
Page 0017 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0018 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Apple-II
Pointers and Mailboxes
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 001 9 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0020 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
i\.>
loo -
Distributed under the Creative Commons License on page 5
Page 0021 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0022 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Apple
-II 2716 EPROM Adaptation
( '
D0' and ' D8 ' Sockets )
18 November 1977
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 0023 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0024 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
11-18-77
WOZ
APPLE-ri 2716 EROM ADAPTATION
('DO' and 'D8' sockets)
Remove the ' EO ' ROM from Its socket. On the top side of the board
under the ' EO ' socket, cut the ROM pin 18 jumper trace. Then
reinsert the ROM. This cut will isolate pins 18 of ROMS 'DO'
and 'D8' from pins 18 of the other ROMS. Reinsert the 'EO' ROM
when done.
EO SOCKET'
>:
\ (Pin 1)
Cut this trace
2. On the underside of the APPLE-II board, cut the traces connecting
pin 20 to 21 of ROMs 'DO' and 'D3' only.
3 On xhe underside , cut the trace going to pin 18 of ROM ' D8 '
near the chip. Scrape solder resist off of approximately \ inch
of the remaining trace not still connected to pin 18, You may
wish to tin it with solder since it will later be soldered to.
4. (Underside) Connect pin 18 of ROM ' D8 ' to pin 12 of ROM ' EO '
(ground )
5. (underside) Connect pin 18 of ROM 'EO' to the trace which
previously went to pin 18 of ROM 'D8' (and which should be
pretinned if step 3 was followed).
Distributed under the Creative Commons License on page 5
Page 0025 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 2
6. (underside) Connect pin 21 of ROM 'D8' to pin 21 of ROM 'DO'.
Thon connect both of these to pin 24 of eithe'r ROM (Vcc)*
7. Xote that the TnH control function (pin 32 on the APPLE-II
I/O BUS connectors) will not disable the 2716 EROMs in the
'DO' and 'D8' ROM slots since pin 21 is a powpr supply pin
and not a chip select input on the EROMs.
Distributed under the Creative Commons License on page 5
Page 0026 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Using Apple-II Color Graphics
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 0027 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0028 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
U SING A PPLE- 1 1 COLOR GRAPHICS
The APPLE-II color graphics hardware will display a 40H
by 48V. grid, each position, of which may be any one of 16 colors.
The actual screen data is stored in IK bytes of system memory,
noj-mall^ locations $400 to $7FF. (A dual page mode allows the
user to' alternatively display locations $800 to $BFP). Color
displays are generated by executing programs which modify the
'screen memory'. For example, storing zeroes throughout loca-
tions $400 to $7FF will yield an all-black display while storing
$33 bytes throughout will yield an all-violet display. A number
of subroutines are provided in ROM to facilitate useful operations.
The x-coordinates range from (leftmost) to 39 (rightmost)
and the y-coordinatcs from (topmost) to 47 (botto mnost ) . If
the user is in the mixed graphics/text mode with 4 lines of text
at the bottom of the screen, then the greatest allowable y-
coordinate is 39.
The screen memory is arranged such that each displayed
horizontal line occupies 40 consecutive locations. Additionally,
e\en/odd line pairs share the same byte groups. For example,
both lines and 1 will have their leftmost point stored in
the sar.ie byte, at location $400; and their rightmost point
stored in the byte at location $427. The least significant
4 bits coriespond to the even line and the most significant
4 bits to the odd line. The relationship between y-coordinates
and memory addresses is illustrated on the following page.
Distributed under the Creative Commons License on page 5
Page 0029 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
COLOR GRAPHICS SCREEN MEMORY MAP
Y-coordinate
OOabcdef
BASE (leftmost) address
OOOOOlcd
GBASH
eababOOO
GBABi;
Data byte
XXXXYYYY
odd
line
data
even
line
data
Secondary
LINE
BASE address(hex)
BASE add
$0,1
$400
$800
$2,3
$480
$880
$4,5
$500
$900
$6,7
$580
$980
$8,9
$600
$A00
$A,B
$680
$A80
$C,D
$700
$B00
$E,F
$780
$B80
$10, 11
$428
$828
$12, 13
$4A8
$SA8
$14, 15
$528
$928
$16, 17
$5A8
$9A8
$18 , 19
$628
$A28
$1A, IB
$6A8
$AA8
$1C, ID
$728
$B28
$1E, IF
$7A8
$BA8
$20,21
$450
$850
$22,23
$4D0
$8D0
$24,25
$550
$950
$26, 27
$5D0
$9D0
$28,29
$650
$A50
$2A, 2B
$6D0
$AD0
$2C, 2D
$750
$B50
S2E, 2T
$7D0
$BD0
Distributed under the Creative Commons License on page 5 I Page 0030 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The APPLE-II color graphics subroutines provided in ROM
use a few page zero locations for variables and workspace. You
should 'avoid using these locations for your own program variables.
It is a good rule not to use page zero locations $20 to $4F
for any programs since they are used by the monitor and you may
wish to use the monitor (for example, to debug a program) without
clobbei^ring your own variables. If you write a program in assembly
language that you wish to call from BASIC with a CALL command,
then avoid using page zero locations $20 to $FF for your variables.
Color Graphics
Page Zero Variable Allocation
GBASL $26
GBASH $27
H2 $2C
V2 $2D
MASK $2E
COLOR $30
GBASL and GBASH are used by the color graphics subroutines
as a pointer to the first (leftmost) byte of the current plot
line. The (GBASL), Y addressing mode of the 6502 is used to
access any byte of that line. COLOR is a mask byte specifying
the color for even lines in the 4 least significant bits (0 to 15)
and for odd lines in the 4 most significant bits. These will
generally be the same, and always so if the user sets the COLOR
byte via the SETCOLOR subroutine provided. Of the above variables
only H2, V2 , and MASK can be clobbered by the monitor,
Distributed under the Creative Commons License on page 5
Page 0031 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
Writing a color graphics program in 6502 assembly language
generally involves the following procedures. You should be
familiar with subroutine usage on the 6502.
1. Set the video mode and scrolling window (refer to
the section on APPLE-II text features)
2. Clear the screen with a call to the CLRSCR (48-line
clear) or CLRTOP (40-line clear) subroutines. If you
are using the mixed text /graphics feature then call
CLRTOP .
3. Set the color using the SETCOLOR subroutine.
4. Call the PLOT, HLINE, and VLINE subroutines to plot
points and draw lines. The color setting is not
affected by these subroutines,
5. Advanced programmers may wish to study the provided
subroutines and addressing schemes. When you supply
X- and y-coordinate data to these subroutines they
generate BASE address, horizontal index, and even/odd
mask information. You can write more eff icient , programs
if you supply this information directly.
Distributed under the Creative Commons License on page 5
Page 0032 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
S L TCOL s 11 b r o u 1 1 n e ( ^<'5diltls_s_$_FS^4)
Purpose: To specify one of 16 colors for standard resolution
plott ing .
Entry: The least significant 4 A-Rdg bits contain a color code
(0 to $F). The 4 most significant bits are ignored.
Exit: The variable COLOR (location $30) and the A-Reg will both
contain the selected color in both half bytes, for
example color 3 will result in $33. The carry is cleared.
Example: (select color 6)
LDA =i$6
JSR SETCOL ($F864)
note: When sitting the color to a constant the following sequence
is preferable.
LDA #$66
STA COLOR ($30)
PLOT sub routine (address $F800)
Purpose: To plot a square in standard resolution mode using the
most recently specified color (see SETCOL). Plotting
always occurs in the primary standard resolution page
(memory locations $400 to $7rF).
Entry: The x-coordinate (0 to 39) is in the Y-Reg and the y-
coordinate (0 to 47) is in the A-Reg.'
Exit: The A-Reg is clobbered but the Y-Reg is not. The carry is
cleared. A halfbyte mask ( $F or SFO) is generated and
saved in the variable location MASK (location $2E),
Calls: GBASCALC
Example: (Plot a square at coordinate ($A,$2C))
LDA F$2C Y-coordinate
LDY #$A X-coordinate
JSR PLOT (F800)
Distributed under the Creative Commons License on page 5
Page 0033 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
_P I. OTl su brout ine (addro s s $FSOE)
Purpose: To plot squares in standard resolution mode with no
Y-coordinate change from last call to PLOT. Faster
than PLOT. Uses most recently specified COLOR (see
SETCOD)
Entry: X-coordinate in Y-Reg (0 to 39)
Exit; A-Reg clobbered. Y-Reg and carry unchanged.
Example: (Plotting two squares - one at (3,7) and one at (9,7))
LDY ^^$3 X-coordinat^
LDA #$7 Y-coordinate
JSR PLOT Plot (3,7)
LDY ^$9 New X-coordlnate
JSR PLOTl Call PLOTl for fast plot.
HLINE s ubroutine (addres s $F819)
Purpose; To draw hori:<;ontal lines in standard resolution
mode. Most recently specified COLOR (see SETCOL)
is used.
Entry; The Y-eoordinate (0 to 47) is in the A-Reg. The left-
most X-coordinate (0 to 39) is in the Y-Reg and the
rightmost X-coordinate (0 to 39) is in the variable
H2 (location $2C). The rightmost x-coordinate may never
be smaller than the leftmost.
Calls: PLOT, PLOTl
Exit; The Y-Reg will contain the rightmost X-coordinate (same
as H2 which is unchanged). The A-Reg is clobbered.
The carry is set .
Example; Drawing a horizontal line from 3(left X-coord) to
$1A (right X-coord) at 9 (Y-coord)
LDY #$3 Left
LDA ^SIA Right
STA H2 Save it
LDA i^$9 Y-coordinate
JSR HLINE Plot line
Distributed under the Creative Commons License on page 5
Page 0034 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
S C RN subr ou tine (add ress $F8 71)
Purpose: To sense the color (0 to $F) at a specified screen
posit ion .
Entry: The Y-coordinate is in the A-Reg and the X-coordinate
is in the Y-Reg.
Exit: The A-Reg contains contents of screen memory at specified
position. This will be a value from to 15). The Y-Reg
is unchanged and the 'N' flag is cleared (for unconditional
branches upon return).
Calls: GBASCALC^
Example: To sense the color at position (5,7)
LDY #$5 X-coordinate
LDA j7$7 Y-coordinate
JSR SCRN Color to A-Reg.
GBASCALC subroutine (address $F847)
Purpose :
To calculate a base address within the primary
standard resolution screen memory page corresponding
to a specified Y-coordinate. Once this base address
is formed in GBASL and GBASH (locations $26 and $27)
the PLOT routines can access the memory location
corresponding to any screen position by means of
(GBASL),Y addressing.
(Y-coordinate)/2 (0 to $17) is in the A-Reg. Note that
even/odd Y-coordinate pairs share the same base address)
The A-Reg is clobbered and the carry is cleared. GBASL
and GBASH contain the address of the byte corresponding
to the leftmost screen position of the specified Y-coord.
Example: To access the byte whose Y-coordinate is $1A and whose
X-coordinate is 7.
Entry
Exit
LDA F$1A
LSR
JSR GBASCALC
Y-coordinate
Divide by 2
Form base address.
LDY
X-coordinate
LDA ( GBASL), Y Access byte
Note: For an e\en/odd Y-coord pair, the even-coord
cc^ntaitiL-d in
byre and the
the least
odd-coord
significant
data in the
data is
4 bits of the accessed
most significant 4.
Distributed under the Creative Commons License on page 5 I Page 0035 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0036 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Adding Colors
to
Apple-II Hi-Res
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 0037 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0038 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
ADDING COLORS TO APPLE-II HI-RES
(nullifies warrantee)
1. Remove the APPI,E-II PC board from its enclosure
{ a )
Drin-,/^i-o tHra + c:ir\ 1 H ^ c r- c; Q <=> r< 11 "P 1 n Cr thp D 1 3 S t i C tOD DieCS
to the metal bottom plate. Six (6) of these are flat-head
screws around the perimeter of the bottom plate and four (4)
are round-head screws located at the front lip of the computer.
Ail are removed with a pnixllps neaa screwarivtjx , i^u ijut
(b)
Lift the plastic top piece from the bottom plate while
tQirincr nuTfi nnt to dnmapp thp ribbon Cable Connecting the
keyboard to the PC board. This cable will have to be
disconnected from one or the other.
(c)
Disconnect the power supply from the PC board.
(d)
Remove the -8 nut and lockwasher securing the center of the
PC board. These will not be found on the earlier APPLE-II
computers .
(e)
Carefully disengauge each of 6 nylon posts irom the Jr-L Doara.
(7 on earlier versions).
(f )
Lift the PC board from the bottom plate.
Distributed under the Creative Commons License on page 5 | Page 0039 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 2
2 . Above the board wli-lng method
(a) Lift the following IC pins from their sockets.
A8-1
AS-6
A8-13
A9-1
A9-2
A9-9
(b) Mount a 74LS74 (dual C-D flip-flop) and a 74LS02 (quad NOR
gate) in the APPLE-II breadboard area (All to A14 region).
(c) Wire the following circuit (♦ indicates that wiring is to
a pin which is out of its socket).
Distributed under the Creative Commons License on page 5
Page 0040 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
■j:
.4-
) fl y, j/ a. 7HL - ■/ ■
1 A 1 C- l' r- I. r f f
cr^.^^s- thai JJ''^-'
sccl'et)
—t-rc >f — J-
c
i
\'' C c
if-'
7- '3-*' ,
I
L -
\ )
Distributed under the Creative Commons License on page 5 I Page 0041 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
Distributed under the Creative Commons License on page 5
Page 0042 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Apple-II
Disassembler Article
( Apple-II MONITOR ROM )
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 0043 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0044 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
DISASSEMBLER ARTICLE
(pertains to APPLE-II MONITOR ROM)
Distributed under the Creative Commons License on page 5
Page 0045 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
Distributed under the Creative Commons License on page 5 I Page 0046 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
5
D
.4
v. U
J - (U
,1-;
I
LI
(-)
<
r_
-,
-
O
>
-V
■'^
1-
!_
Kj
->
C
#.
1 J
I--
*>
p.
><
<C
\J
l-
<
rr
0-
"2
O
""3
v_ ""J
5^ './I
CI.
-5
Z
<-;;
c
Z
"3
M
U
1
^■
.1
1,-1
c
-O
(-
■■c
^ a.
<
a:
c
C -f-
X
lb
1,
o
x:
C
h
r~
o
ft:
. ^-
<
SJ
,1 'o
o : ^- ^ ^ c ^ : . - c ^ - rn
■ -
^1 c r - ^ ■- - L <j
(/■ - r - ^ ^ .1 r c
■ - :i- ~ or
-1
C
G
O
"J
1! u U
S 5 3 S S 3 3' c5 ^
Distributed under the Creative Commons License on page 5 | Page
0047 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
Q_
i
O
_l (-
cC H
Q 5.
Q-
Oo U
J
I
— S
3
3 4j
i. -
0-
~ 2
^ a.
- ^
-r-
•N
_:5 -
1/1 u
■i.
u. S
-A
%
U
L.
■u
cr
)
H
s
11
a.
~4
t
6
<
cr
5
-V
CI
o
5k
' oc
I,
4.
D —
IT)
^ +^ ^
J - a'
5 "V.
5 ^ ^
^ V9 _/ -
z 2:
O 5 21
Li- .J V-
-(S ... ^, .v. ^
^ ^ ^'
o
a
a.
C",
Distributed under the Creative Commons License on page 5 I Page 0048 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
w
y -
u
V
15
> •
a- L
**
< '
h
1"
V.r
u
c
rv
C -1-
W
1— ^
_^
^ -XT
. ^
'z
O
V
:^
D
1^
•i
••J
a
t
o -
51
-5 ^
— X
0- o I
0.
a,
u
»:
to
Q
u
0-
I)
■•J i,
X ^
^ J-*
v.,
H
<
u
0-
a
u
Distributed under the Creative Commons License on page 5 I Page 0049 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
-1
o
5.
Li
V
(r
'I
1.
^/
a
0/
f-
1.
-I- ^
1, L
i/1
Uii IN
-"v ^
C: =r
c- K K
^1
0-
.j->
1)
jr.
1.^
c
G"1
^ 'i-
•A
1
— 1
■b
\
o
1\
■f>
>
\i
\-
c-
L-
o
c
r
Distributed under the Creative Commons License on page 5 I Page 0050 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
3
-a
o
O
c
o
o,
3
+
J)
-■Q
£
10
u
u
rf—
rw -
H
'I
a
£
•t-
j-
u
><
e:
,0
-K
c
US
Q.
ci
Q.
a
I- ^
to < -J
Z u u
H Q- CL
CI
. c
o
Q
1
U .
0- o
u
CL D-
O
(J
4-
4-
o
\
E
>
Ui
in
o
X
X
X
i
o
V
-A
z
<>
H
aJ
>
£
£
1; +
. \
+-
Si. '0
"s. ^
_ -o ,5
^ ^ 1
V-
o
CD
to
"3
a.
t)
-c
L
Q
o
o
a
>;
D
<^
u
-c
o
"5
4-
^)
-J i
u
-C
, C
X
ii
:^
+;
\j
c
"3 <
-Q
C)
•Si
c
-a
L
1
to
d
ts
-^- c
d
^
o
a_
o
-)-
c
u ~
1-
>
c
J.
-+-
^
c
><
aJ
-«
L
4;
w
C
a.
<
c
■4-
<+-
s.
c
H
H
H
H
4 ^
J
CO
E
o
Q.
z
UJ
>
UJ
H
a:
or
^ a: ^
i>
UJ It
00
>; 1x1
*- a
Ui o
Z cr
V-
u
h
ui
CO ^
N <
ul 2.
O ^
<<ccc£<>-uL^a:<>aUcrt/?Q-OQ<crK<ioa:a:c:o:^tJ)-<><<<ra
So
CO
to Co
Q
>
u
bJ
O
O
I
c:
h
h
p-, ^J Li^ tr l;i
^ ~- 1^ ;^
l;i M) N n
> Li- Q ;^
CD
— CM —
0-
^ ^ ^ ^ ^ ^ ^ ^'-Q ^ > X CO Q i.; ! ^. - -'^
C^; Cy,
^4 p^ r,, ^1 \ f'l
I Page
Distributed under the Creative Commons License on page 5
0051 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
*i ' 4: -T^
-a ■- +1
A ^
^ ■ ^
'■^ ■■" < X' >< K X >^ ' ^--^
• ^ ■ " -'^ - ' -
■ : ^ t ^ 1 L
V .5 ■■ ^ ^ a la. ^ -° ii ■ - 1-
aj -L ! ^ X ^ X £ ^ ^ *J ^ ^
'^-^'''^ ,0X50^5 >'-2. -Cr
O^^o Ll-_XXXX W '-^ J y 0=-
u«Jrf" ..... > 0-1 i/ -^
^
z 00, (Ti 00 1 # z z h^cr^Kui cc^v^vq: ^^^^
_ H ro J
■ . y- >< K
S CD Q . a ql
z z zoo
2 z z q: (X
Lj-
. Ll Oo . cr (T
? .^ScO C ^ 5 ^0-U;^ ^^^^ ^
2 ^ ^ > ^ 5 > ?^ ^ '^1 M-^ ^ '-j >: -b^ t ^ ^, ^- I.. ^- -
1
J
Distributed under the Creative Commons License on page 5 | Page 0052 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
S
o
I
d
ti
u
10
to
«0
Z 2
^ ^ 2. i.
^ ^ a: ^
o
i
£
>
£
V
u
•V
w
-ij
or
c!
1.
4-
9i
4-
.-^
C
u
1-
0-
OJ
J.
s:
£
di
o
■h
ro °
^
II
-TS
^
<+-
<
O
H
1SL
II
or
f-
z
_1
0-
o
Z
4-
5
<^
£
c
t.
4;
V
u
>
<i
V —
£
^
c
' -
c
o
4—
'a.
ID
o
-(-
' c
>-
i.
ft
^ -f—
■t—
u
1 i.
o -
O
M
i.
-f-
X
v.i
— o
1>J ^
= tSi
<.
-T3
d "J"
u
X
O
1- •
O
3
a:
N
Z
E
a:
a
r>
o
a
<
X
o
Z
(X.
a.
z
cc
a
< z
Q- -I
cr < .
^ c: uJ
^ o H
or O
a u-
< y
J CD
a:
ct
^ ^
" t; -
^ ^ cc 1 O H ^
<□:<<<:<<<
cr O or X X
CL Lu Q. u
K i- ^
h
O
T
U
Q-
cr
o
<:
(X
a
s 2:
o: d
a. 0.
o
<
Q.
(X
Q
<
a:
or
o
<
o:
CL
=1-
(X
o
<
(X
D-
Ll to ■ o-u.cr,L,
C- to f.-^ ^ > cr- o =^ ^ > ,S; iS >^ C: ■ " ^
fcr> Co ^r. U:, Cfl C/:, . 1^ C<> tjQ t„ {Vi to to i'j tx; -^^^ ^ — -~- •>
Distributed under the Creative Commons License on page 5
Page 0053 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
u
£
o
6
a.
1
X
u
0.
«»
J
u
0.
ro
O
<
u
a
o
c
d
to
c
(U
L.
J
a.
cr
CL
ul
I-
y
CQ
a:
Q.
(-
>-
CD
Q-
o
h
O
<
x
o
X
Q. CL
_1
u
o
a.
a.
o
<
_J Z
u cr
CL
II
£ -i
o
O CO
h
O
<
-Si
to <
o
D
O
cr
<
£1-
o
_i
* ^ It * U
rl
CO
a:
O-
A
to
II
-CI
II
-(-
-a
li
X
h
y
I/)
I-
X
<J
<
0-
■ —
. —
i
^ — ^
n>
L.
u
~tS
o
>s
— Q
>
\-
IT)
o
«J
■2
'c
lu
_J
-IS
»v
+
w
0)
-)-
_)
<.
U
U
to
0-
X
u
CL
1-3
o
<
u
CL
-I Kf)
n->r><iJ:K<a:<Q-<-Q:<>rCC<a:><<cr><:i-Jto<<-^)-><-J>'^^^'^
<
UJ
>-
H-
2
tr
Q.
z
cr
Q-
X
h
z
or
a
u
Q.
q:
Z rM m
-J -1 _j
(D 03 02
cc cc a:
Ql. Q_ a.
1-3
a
<
O.
CO
< <
u u
a CL
:^
<
L)
Q.
cr
6o
Ll
It- ■ ■ u.
U Q Li. Irj
Cj Cb UJ ^ >
Oo
U
's;: UJ K Ul
00
IL
00 ^^ 0} u U.-'<Si, ^ U II ^ 'vj) \i ffi y 1^ k CN ;^ X c
I Page
Distributed under the Creative Commons License on page 5
0054 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
« ^ ^
'SI. la. m
~ —v-i
iT) IS lO
^
N ca* rx]'
^ 13. rsj
<^ v> «,
O Si -Q. IS), > ;f
3- cr ^ ^- ;t ^
■H ■*» *» -n? »»■••*■
•^ », ^ «, ^ «
1^ ^ (a (NJ u
^ <S. 'Q, i^i, (N to
*v -or
(N O
(S( do
=1- ^
:i- ^ Co
;^ ;j-
* 1
N to
(S ^ (N >a^_
-» t» t»- i*. »!-
^ g 13 i£ 1^ ^ ^ ^ 1^ ^ ^" N
COcDoDcQcOcDaQoQcQCDCQcDcIDcQcQCQcO
Ll-LuU.LL.b.U. U.UU-L.1.^ U-U-LlUU-U.
QOClCiClQQCQQQOQCiOOQ
Q
O
^ c'l a- "fS.^^^ ^, 0^ r-^ ^ m ^
^ ^ ) V (i) 1^ (x; "t^ fO o r--;) ^ ro \ <
^ > b
•i. ^ ^ V ^ ^ ^ fN ^ >a -
^-^ "i. V V V"^^^ ^ - K t -N. ^ ^
^ ^- >. ^ ^ ... ■, ^ - <J > Kj ^
'^->- ^ - ^ >\ % '■^^ '""^ "'i '""'^ ^
oc
Z ^ ui O
E I CD £ U
t-t t<l H <
°- ^ a.
(0 CQ
CD Q.
J
111
i>3 < < sj cvi a:
TarS'o6oia.'s.i03-<ro-oo*ooo-
cQcQcQcQcDcDCDcOcDaJCQCDcflCQ
LLU.UIXI4.U.I-1-IJ.IJ.U.U.U.U.U.
U
Q
O
3^ N^V-^Cs.~-(\jvX)^l/>Q-
^ ^^ t« ..t£i S.. 'A ^ o- 1^
■N c^, 3: ^-0 U =^ ^
^ 5: > S: ^ ^ ^
I Page
Distributed under the Creative Commons License on page 5
0055 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
>
*f -
*»
**
•>
X
'a
*
•>
CO
CO
u.
u.
Q
Q
or
oc
<
I
u
u
>
•5:
t;
■5:
(r
Q
r\
m-5-^roia>
" I I *
^ Q cr' 0- ^
o cr (D
N N
OOCQCorocr ^u-Cr
V, V, V, ^ *» H n
• ^ * ^ J" *" vT
M *»•
Co to'N^-<o~-
-V, V>r 1^ *^ M
'■ tl "1 •\ ^ ^
U Q 'Si, ^ Lj :;r~
COCDCQCDCCICQCDCQ
Ll Ll U. Ll Ll Ll U. U-
K
IS — ~
> - ^
X X ^ ^
X -
o5 , "ij
c> tr- .'3- ^ ^
t\j IJ) ts f^ l>CQ Cs'^
tvT to U N VC
t» H
DO
:r ^ ■tr ^ ■s- <r ^
It iSl IN ^ —
^ M vt- vt « -n *
CQcQCDtQ CCCOcQCD
U_U.U-a.LLLi.U.U.
^ r—^
6
o- Cr- > > :>
I Page
Distributed under the Creative Commons License on page 5
0056 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Apple-II
Cassette Article
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0057 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0058 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
CASSETTE ARTICLE
Distributed under the Creative Commons License on page 5
Page 0059 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
Distributed under the Creative Commons License on page 5
Page 0060 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
A r, I,
crrAcJ oy^ cx iir-.^le f a p e , oi^eL Tr r-x-Tttt-
£1
,c:,'o,J f'fc h^ip.v i,.sed. Eiiher reco'd ^na/
1
/ t I S .
-r'l (X 'cold ri a.r-'i a'f
I
1 1
Distributed under the Creative Commons License on page 5
Page 0061 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
s
Y
7:.. ^....r-
7>'. .
I
Distributed under the Creative Commons License on page 5
Page 0062 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
T t, e
e I c
1 5^
r 1 /■ T
fc 77 f
Bt re-
fc' r TJT
/
t
s
B
B
— I'l-'iJ .i.JtC >^
j er ■i' J e c_
or I Of' ^ ; l> y / -t J'
) a c \ 1 I O )
' c \ o c \ \ o
\ \ i o o )
Distributed under the Creative Commons License on page 5
Page 0063 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
r
7 'I > ^
D
e
I o K
Ti'i- JV/TE X,-
D 7 <
3 K
; 00 f.
T O
r-^i I c
TO
£~r\H
3 /i c <
may i?e ".i e d
("ij If av. r,, vtiier Tj a<--r.Vi-c;l -fn; r a J r J' -c
»
■ V
-> I ^ - r I tfc di O u."t"|; I. f-
Distributed under the Creative Commons License on page 5
Page 0064 of 0213
The Woz Wonderbook -- 1977
-- DigiBarn Computer Museum --
>
Steve Wozniak, Apple Computer Inc.
i f- r V v /\ fi t_
t e-i" L - k,'c- k
e
4-. ,. /
c
'\ o 1 c| is e 1 so~
. ■ i
i c f.1 i n £? s .
A. t , 1
f c c c'c- /-.pli j" )i e d
-{olio w. S '■
t
( 1 )
t- J K 1
Y-
c i ' '1 c,ii-\ L tf r
o~f
e <3
)
e. '. Th/f V <x / u e
v
1
: I n
■fa p i;? c n-~f
"fo g c, 1
& . C A, \ y If c ( e<a r
z d -ie o< "
> /- 1 »
i" If. v>.' R e I T
\ s
ti f>> €-
£5 t^rt" t) tfi. J" e d o. ,
Y - R ^ f £>.^..-+ )
a. £^
I
. ti.
/4 " ^ c . f , c '•^
X " K E'lS- c{ e c i e e
'\'t<r:<d' , a n Tlx -fi
^ - ^€C-
N e
r
I e ' ■^A'i f'f ^ £ c \'e
"Tl,,V
{ s u J e 1 0- !
Distributed under tine Creative Commons License on page 5
1
Page 0065 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
CD "U, c- Y-RES- IS iVi '1 I > =■ ' 4 ^ I- rJ.^A t:
i'c ii. £ i^^i'k ^ixke^ i".Vit-e .pri'or ia^^eito
'55
0?) P.PB_LT ^ i rc f-f ,\ e )> ca.lleJ!. J-t ^("1/ loop
Rps&XT /? uv/i^ i cl-, lis 1^ [> 15 I 1
Tcy't ... ^
' '--^^f' ^' /o ./ ; - ..X ^/V, \ns-TiU
Distributed under the Creative Commons License on page 5
Page 0066 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
left fn il.d /\ •^fc.-^S--. X I'f c|e=tft.f^.
(^l) Isc.r ( .r.. Ii £ tf'.-r iAe f ^ fe liefer J
(Pi i ^ , A \ h ) o^<^ C A ^ Az H ) e
Cz) C ck\( w fiX-T S
(i) s^..c lit ^.^.iic^.
^ r eater "i'ha^ (A e A ^ H ) .
Distributed under the Creative Commons License on page 5
Page 0067 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
'^■'<j tic. iii<rfi',^^ anA Crx^iy,^ aAd^e-rsCr
~f<r r fly ijccK cf cfai^i fo I e. re <:^A ■
^ Cm) ^^^is 3 x^rc..,^^ -far 1~(^f^ fo re^cL
^ft.C ci ■
(cj lc-o]< '^-^r To.yeiy^ '^'^SJ^C-
C^) i D.^, c-^ i> t." L c .
ore i^J^d
Distributed under the Creative Commons License on page 5
Page 0068 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
(
He: l-^-Lif- ^i<xrff^^ a^ddy-e-f-r ~fo r 'tk <^ Jc^in
"■' e ^ f^.' ./p. :.-^d S /v f O r^.'^,-,^/ f^r
Distributed under the Creative Commons License on page 5 | Page
0069 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
'^-^ enter Tk<2. Ca-i-r<3~ffe, -t=^-?*^^^=E"- Tf^'fiV. ex
'V> ^ (f r» n a n e "
hlo.k -h, ^ritie^. \,>^-arc(e,r
li .'jf I - a, J Si \-^,a l-f A <H ■
Distributed under the Creative Commons License on page 5
Page 0070 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
\ c ;
A- i c3 ^^ -C '1-1 f't^
(<<-
(?,^
ar
r-fc ,
J
<r / ' f ■ O
^
l ^i- A
M N
a
nt
^/^ ^it
n
e re. ccy^t/c. r
1 n
''^ ^ 1^^^^ e j-
it/ 4e ir^ i." H % </
t'f-''(r<. (
-He
J <^ c
■ c )
v_ ^ -
n
cite f-J L<
If
Z' f\ 1,'. V ^ L ^-
r
e- 7
U 1 ■
/
Distributed under the Creative Commons License on page 5
1 Page 0071 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
I >-A
A I L
A I H
Az L
i
I
-y-f^T- ti i^Cl i ^-e-tz trr-. — ><j /'V £_ iL~
Distributed under the Creative Commons License on page 5
Page 0072 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
u . • 1 ,\ . ^ . , y ^- yV nu li', ' - y
Distributed under the Creative Commons License on page 5
Page 0073 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
.1 V- . c- 7V J Y<r ci ^.<£, I ,.'tc r-fci c <£. Ai'rtiF # ^ e f
,.:ih\:,,j iris ^ritc^. T /«/'Aw e. us,^^ 7^
o ^ s
r. ,^7_, /cT'j 7^'/£
71]
d
( C> et c J" J" I r\ J £ 1*
r
J-
<ir-J refer
TA
I Page
Distributed under the Creative Commons License on page 5
0074 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
r ' '
o 6 r
3
1^0
,^^tl -f},e fe^t/ a^-f</ i^i-ni-e crf^^/i fi\
3 K'^^
Distributed under the Creative Commons License on page 5
Page 0075 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
Distributed under the Creative Commons License on page 5
Page 0076 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
1 O 1- i
, r H
^1
Is?
^ y y.:.;-
W ► -
■n
-.LL
'c-'i'
r-,n
R2
FF
r,.j
r C
r-j
CB
CF
ES
FO
K7
20
IE
Fl
a3
yl
pi
20
t'.H
DS
r M
FC
83
16
28
i"u
.-tC
CJ
2E
'"•■"(
cv
FH FC
. '
FC
Fy
23
TL-'
FC
28
EC
FC
2:E
vE
BF
FC
Kv
34
Fl-
•iL
ER
- t-
Es
Eh
EE':
2 '3
FF
FD
Bl
0-
Dh
FD
Kb'
Ho
ED
FD
L-T:
C'-
FD
r r
CL
-■J
SIX
l3x
L.Dfl
SEC
STfl
FEQ
m
■JSR
LDX
JSR
m
RTS
.JSR
LC'B
JSR
STfl
JSR
LC'V
JSR
ECS
JSR
LDV
JSR
B£Q
, EOR
STR
iTJi'F J.
V4
?|-CFfl
.f5c5 ( ^z-
?FC-.'fl
^?24 ^
XFCFD
^FCFC-
-■■0
LiH
irr.
Ftfl
JSR
?rF2D ^c-f?-^ '(ir^-e'^
5rL>92 fo J-K D- ;
$F[:€D
$r3DFi -i ^ '
J' JEC <-
Distributed under the Creative Commons License on page 5
Page 0077 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0078 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Apple-II
Floating Point Package
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0079 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0080 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
FLOA TING POINT PACK-AGE
The mantissa-exponent, or 'floatingpoint', numerical
representation is widely used by computers to express values
with a wide dynamic range. With floating point representation,
the number 7.5 x 10^^ requires no more memory to store than
the number 75 does. We have allowed for binary floating point
^arithmetic on the APPLE-II computer by providing a useful
subroutine package in ROM, which performs the common arithmetic
functions. Maximum precision is retained by these routines and
overflow conditions such as 'divide by zero' are trapped for
the user. The 4-byte floating point number representation is
compatible with future APPLE products such as floating point
BASIC.
A small amount of memory in page zero is dedicated to the
floating point workspace, including the two floating-point
accumulators, FPl and FP2 . After placing operands in these
accumulators, the user calls subroutines in the ROM which
perform the desired arithmetic operations, leaving results in
FPl. Should an overflow condition occur, a jump to location
$3F5 in RAM is executed, allowing a user routine to take appro-
priate act ion .
FLOATING POINT REPRESENTATION
HI
LOW
Exponent Signed Mantissa
Distributed under the Creative Commons License on page 5
Page 0081 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
1 . Ma n tj. ssa
The floating point mantissa is stored in two's complement
representation with the sign at the most significant bit (MSB)
position of the high-order mantissa byte. The mantissa provides
24 bits of precision, including sign, and can represent 24-bit
integers precisely. Extneding precision is simply a matter of
adding bytes at the low-order end of the mantissa,
— 1 28
Except for magnitudes less than 2~ (which lo^e precision)
mantissas are normalized by the floating point routines to retain
maximum precision. That is, the numbers are adjusted so that the
upper two high-order mantissa bits are unequal.
High-order Mantissa Byte
I 01 . XXXXXX jPositive mantissa,
' 10. XXXXXX J Negative mantissa.
oo.xxxxxxH
; " ■ \. Unnormalized mantissa,
. 11. XXXXXX j exponent = -128.
2 . Exponent .
The exponent is a binary scaling factor (power of two)
which is applied to the mantissa. Ranging from -128 to +127,
the exponent is stored in standard two's complement representation
except for the sign bit which is complemented. This representa-
tion allows direct comparison of exponents since they are stored
in increasing numberical sequence. The most negative exponent,
corresponding to the smallest magnitude, -12^, is stored as $00
($ means hexidecimal) and the most positive, +127, is stored as
$FF (all ones) .
Distributed under the Creative Commons License on page 5
Page 0082 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
Expon ent S tored As
+1
10000001
($81)
+ 2
10000010
($82)
+ 3
10000011
($83)
-1
01111111
($7F)
-2
01111110
($7E)
-3
01111101
($7D)
The smallest inagnitude whicih can be represented \s +2 ,
EXP
1
CL. J L. 0__ 1 ...1 ._j
high low
MANTISSA
The largest positive magnitude which can be represented
128
is +2 "°-l.
-, , •• ■-, I 1 r
$7F [ $7F ' ^ $FF j $FF
EXP MANTISSA
Distributed under the Creative Commons License on page 5 I Page 0083 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
FLOATING POINT REPRESENTATION EXAMPLES
"1 m Q T
XlUCl X
umber
Hpx
Exponent
Hex
Mantissa
+ 3
81
60
00
00
+ 4
82
40
00
00
+ 5
82
50
00
00
+ 7
82
70
00
00
+ 12
?3
60
00
00
+ 15
83
78
00
00
+17
84
44
00
00
+20
84
50
00
00
+60
85
78
00
00
(l.lg X 2-^)
(l.Og X 2^)
(l.Olg X 2^)
(l.llg X 2^)
(l.lOg X 2^)
(l.lllg X 2^)
(l.OOOlg X 2^)
(l.Olg X 2^)
(l.lllg X 2^)
- 3
81
AO
00
00
- 4
81
80
00
00
- 5
82
BO
00
00
- 7
82
90
00
00
-12
83
AO
00
00
-15
83
88
GO
00
-17
84
BC
00
00
-20
84
BO
00
00
-60
85
88
00
00
Distributed under the Creative Commons License on page 5 I Page 0084 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
FLOATING POINT SUBROUTINE DESCRIPTIONS
FCO.MPL subroutine (address $F4A4)
Purpose:, FCOMPL is used to negate floating point
numbers.
Entry: A normalized or unnormalized value is in FPl (floating point
accumulator 1) .
Uses: NORM, RTLOG.
Exit: The value in FPl is negated and then normalized to retain
t
precision. The 3-byte FPl extension, E, may also be altered
but FP2 and SIGN are not disturbed. The 6502 A-REG is
altered and the X-REG is cleared. The Y-REG is not disturbed.
128
Caution: Attempting to negate -2 will result in an overflow
128
since +2 is not representable , and a jump to location
$3F5 will be executed, with the following contents in
FPl.
FPl : ° J i $S0~| J j
XI m.^
Example: Prior to calling FCOMPL, FPl contains +1=
FPl: , $83 1 $78 ; J |
(+15)
XI Ml
After calling FCOMPL as a subroutine, FPl contains -15.
FPl: $83 ~' $88 : l °
(-15)
xi ~ Ml ^
Distributed under the Creative Commons License on page 5
1 Page 0085 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
FADD subrout ine (a ddress $ F46E)
Purpose: To add two nujiibers in floating point form.
Entry: The two addends are in FPl and FP2 respectively. For
maximum precision, both should be normalized.
Uses: SWPALGN, ADD, NORM, RTLOG.
Exit: The normalized sum is left in FPl. FP2 contains the addend
of greatest magnitude. E is altered but SIGN is not.
The A-REG is altered and the X-REG is cleared. The
Y-REG is not disturbed. The sum mantissa is truncated to 24 bits
Caution: Overflow may result if the sum is less than -2"""^®
128
or greater than +2 -1. If so, a jump to location
$3F5 is executed leaving in XI, and twice the proper
sum in the mantissa Ml. The sign bit is left in the
carry, for positive, 1 for negative.
FPl: 1 [x.YVY... ;
— -I L , _ i
XI Ml
(For carry=0, true sum = +X.YYY... x 2^^^.)
Example: Prior to calling FADD, FPl contains +12 and FP2 contains
-5.
FPl: I $83 " $60 | (+12)
XI Ml
FP2: $82 $B0 ' (-5)
X2 ' M2 '
After calling FADD, FPl contains +7 (FP2 contains +12)
FPl; I $82 . $70 ' ■ I (+7)
yi~~ ' Mi~"
Distributed under the Creative Commons License on page 5
Page 0086 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
Fj5LiB_subrc)ut :_ne ( address $F168 )
Purpose: To subtract two floating point numbers.
Entry: The minuend is in FPl and the subtrahend is in FP2 , Both
should be normalized to retain maximum precision prior
to calling FSUB,
Uses: FCOMPL, ALGNSWP, FADD, ADD, NORM, RTLOG .
Exit: The normalized difference is in FPl with the mantissa trun-
cated to 24 bits. FP2 holds either the minuend or the negatf
subtrahend, whichever is of greater magnitude. E is altered
but SIGN and SCR are not. The A-REG is altered and the
X-REG is cleared. The Y-REG is not disturbed.
Cautions: An exit to location $3F5 is taken if the result is
128 128
less than -2 or greater than +2 -1, or if the
128
subtrahend is -2 .
Example: Prior to calling FSUB, FPl contains +7 (minuend) and
FP2 contains -5 (subtrahend).
FPl: I S82 1 I $70 ! | * , (+7)
XI ' ' ¥i~ ' ' ' ~
FP2: I $82 , $80 , ! "j (-5)
X2 ~ M2 ^ ~
After calling FSUB, FPl contains +12 and FP2 contains +7.
FPl: . $83 I S60~| | 1 | j (+12)
XI ~M1~
Distributed under the Creative Commons License on page 5
Page 0087 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
L-'l'^'J:'._''^y.^lil?311ijl<? J ai:ldress_$F48C )
Purpose: To multiply floating point numbers.
Entry: The multiplicand and multiplier must reside in FPl and
FP2 respectively. Bothe should be normalized prior to
ca]]ing FMUL to retain ma.ximum precision.
Uses: MDl, f,lD2 , RTLOGl , ADD, MDEND.
Exit: The signed normalized floating point product is left in
FPl. .Ml is truncated to cont^ain the 24 most significant
mantissa bits (including sign). The absolute value of the
multiplier mantissa (M2) is left in FP2 . E, SIGN and SCR
are altered. The A- and X-REGs are altered and the Y-REG
contains $FF upon exit.
Cautions: An exit to location $3F5 is taken if the product is less
128 1 9R
than -2 or greater than +2^°-l.
Notes: FMUL will run faster if the absolute value of the multi-
plier mantissa contains fewer 'I's than the absolute value
of the multiplicand mantissa.
Example: Prior to calling FMUL, FPl contains +12 and FP2 contains
-5.
FPl:
_?83j [ $60 : ^ . ] (+12)
XI In" ' ^
FP2: I $82j J $B0 ■ I i ^ ! (- 5)
■ X2 ^ M2^ ' ■
After calling FMUL, FPl contains -60 and FP2 contains +5
FPl: $85 _ ^Gs'^ | |" J (-60)
XI " ~M1 '
FP2: 582 ; $50 ^ | ! (+ 5)
1
X2 M2
Distributed under the Creative Commons License on page 5
Page 0088 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
£PJA' g^ broutin e (ad dres_ s SF4B2)
Purpo.se: To perform division of floating point numbers.
Entry: The nqrmalized dividend is in FP2 and the normalized
divisor is in FPl.
Exit: The signed normalized floating point quotient is left in
FPl. The mantissa (Ml) is truncated to 24 bits. The 3-bit
Ml extension (E) contains the absolute value of the divisor
mantissa. MD2, SIGN, and SCR are altered. The A- and
X-REGs are altered and the Y-REG is cleared.
Uses: MDl, MD2 , MDEND.
Cautions: An exit to location $3F5 is taken if the quotient is
less than -2-^^^ or greater than +2'''^^-l.
Notes: MD2 contains the remainder mantissa (equivalent to the
MOD function). The remainder exponent is the same as
the quotient exponent, or 1 less if the dividend mantissa
magnitude is less than the divisor mantissa magnitude.
Example: Prior to calling FDIV, FPl contains -60 (dividend)
and FP2 contains +12 (divisor).
FPl: j $85 ^
XI Ml '
FP2: j $83 "I i $60
(+12)
XI Ml
.After calling FMUL, FPl contains -5 and M2 contains L
FPl: i 582 J \ $BoJ [ ' |~ ] (- 5)
XI Ml^
Distributed under the Creative Commons License on page 5
Page 0089 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
FLOAT ^.-ulirout i ne (a ddres s .$F 451)
Purpose: To convert integers to floating point representation.
Entry: A signed (two's complement) 2-byte integer is stored in
Ml (high-order byte) and Ml+1 (low-order byte). .'11+2
must be cleared by the u.ser prior to entry.
Uses: jNORMI.
Exit: The normalized floating point equivalent is left in FPl .
E, FP2, SIGN, and SCR are not disturbed. The A-REG contains
a copy of the high-order mantissa byte upon exit but the
X- and Y-REGs are not disturbed. The carry is cleared.
Notes: To float a 1-byte integer, place it in Ml+1 and clear Ml
as well as Ml+2 prior to calling FLOAT.
FLOAT takes approximately 3 msec, longer to convert
zero to floating point form than other arguments. The
user may check for zero prior to calling FLOAT and increase
throughput .
* LOW-ORDER INTEGER BYTE IN A-REG
* HIGH-ORDER BYTE IN Y-REG
85 FA X FLOAT STA Ml+1
84 F9 STY Ml INIT MANTl .
AO 00 LDY ,^$0
84 FB STY Ml+2
05 D9 ORA Ml CHK BOTH BYTES
DO 03 BNE TOFLOAT FOR ZERO.
85 F8 STA XI IF SO, CLR XI
60 RTS AND RETURN.
4C 51 F4 TOFLOAT JMP FLOAT ELSE FLOAT INTEGER.
Distributed under the Creative Commons License on page 5
Page 0090 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
(FLOAT c ontinued)
Example: Float +274 ($0112 hex)
Calling sequence
AO
01
LDY
#$01
A9
12
LDA
#$12
84
F9
STY
Ml
85
FA
STA
Ml + 1
A9
00
LDA
#$00
85
F8
STA
Ml+2
20
51 F4
JSR
FLOAT
HIGH-ORDER INTEGER BYTE
LOW-ORDER INTEGER BYTE
Upon returning from FLOAT, FPl contains the floating
point representation of +274.
FPl :
$88
r
88 : $44
J
i $80
XI
J (+274)
Ml
Distributed under the Creative Commons License on page 5 I Page 0091 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
FIX sub routi ne (add res s .' ^F640)
Purpose: To extract the integer portion of a floating pOint
number with truncation (ENTIER function).
Entry: A floating point value is in FPl. It need not be normalized.
Uses: RTAR.
Exit: The two-byte signed two's complement representation of the
integer portion is left in Ml (high-order byte) and Ml+1
(low-order byte). The floating point values +24.63 and
-61.2 are converted to the integers +24 and -61 respectively.
FPl and E are altered but FP2 , E, SIGN and SCR are not.
The A- and X-REGs are altered but the Y-REG is not.
Example: The floating point value +274 is in FPl prior to calling
FIX.
FPl:
$88
XI
$44
$80^ [_ °
(+274)
After calling FIX, Ml (high-order byte) and Ml+1
(low-order byte) contain the integer representation
of +274 ($0112).
FPl :
$8E J |_$01^ I $12 j ~j
XI
Ml
Note: FPl contains an unnormalized representation of
+274 upon exit.
Distributed under the Creative Commons License on page 5
Page 0092 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
A U X I L L I A R Y SUBROUTINES.
a()RM subroutine (audre&s .>i'4bj;
P\irpo.se: To normalize the value in FPl, thus
insuring maximum
precision .
Entry: A normalized or unnormalized value is
in FPl.
Exit- The value in FPl is .normalized. A zero mantissa will
exit with X1 = ( 2"''"^^ exponent ) . If the exponent on exit
is -128 (X1=0) then the mantissa (Ml) is not
necessarily
normalized (with the two high-order mantissa
bits unequal ) .
E, FP2, SIGN, and SCR are not disturbed. The A-REG is
disturbed but the X- and Y-REGs are not. The carry is set.
Example: FPl contains +12 in unnormalized form (as
.OOllg X 2^).
1 r " n r 1
FPl : $86 $0C 1 ;
(+12)
' XI ' Ml
Upon exit from NORM, FPl contains +12 in normalized
3
form (as 1-12 ^ 2 ) .
FPl 1 $83 ' , $60 J j_ "1
(+12)
"Xl" Ml
NORMl subroutine (address $F4 55 )
Purpose; To normalize a floating point value
in FPl when it
is known the exponent is not -128 (X1=0) upon entry.
Entry: An unnormalized number is in FPl. The exponent byte
should not be for normal use.
'■.xit; Tho n :T:alized value is in Ft>l . E, FP2, SIGN, and SCR
are n(.>t rilsturbed. The A-REG is altered but
the X- and
Y-Hi'Gs a re not .
Distributed under the Creative Commons License on page 5
1 Page 0093 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
ADD Kiibr_oii_t i_ne_ (ad duress _$F4 25 )_
Purpose: To add the two mantissas (Ml and M2) as 3-byte iniegers)
Eotry: Two mantissas are in Ml (through Ml + 2) and M2 (-through
M2+2). They should be aligned, that is with identical
exponents, for use in the FADD and FSUB subroutines.
Exit: The 24-bit integer sum is in Ml (high-order byte in Ml,
Ion-order byte in MH-2). FP2 , XI, E, SIGN, and SCR are
net disturbed. The A-REG contains the high-order byte of
the sum, the X-REG contains $FF, and the Y-REG is not
altered. The carry is the '25th' sum bit.
Example: FPl contains +5 and FP2 contains +7 prior to calling
ADD.
FPl
$82
XI
. J I
550
'iMl
1
"1
(+ 5)
FP2
$82
$70
(+ 7)
Upon exit, Ml contains the overflow value for +12.
Note that the sign bit is incorrect. This is taken
care of with a call to the right shift routine.
n r I
•pi
$82 J I $C0 ^,
(+12)
Distributed under the Creative Commons License on page 5
Page 0094 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
ABSWAP subroutine (a ddr ess $F437).
Purpose: To take the absolute value of FPl and then swap FPl
with FP2. Tv'ote that two sequential calls to ABSWAP
will take the absolute values of both FPl and FP2
in preparation for a multiply or divide.
Entry: FPl and FP2 contain floating point values.
Exit: The absolute value of the original FPl contents are :n
FP2 and the original FP2 contents are in FPl. The leasi
significant bit of SIGN is complemented if a negation
takes place (if the origiml FPl contents are negative),
by means of an increment. SCll and E are used. The A-REG
contains a copy of X2 , the X-liEG is cleared, and the Y-REG
is not altered.
HTAR s ubroutine (address $F47D)
Purpose: To shift Ml right one bit position while incrementing
XI to compensate for scale. This is roughly the opposi-t
of the NORM subroutine.
Entry: A normalized or unnormalized floating point value i in
FPl .
Exit; The 6-byte field MANTl and E is shifted right one bit
arithmetically and XI is incremented by 1 to retain proper
scale. The sign bit of MANTl (MSB of Ml) is unchanged.
:?2, SIGN, and SCR are not disturbed. The A-REG contains
the least significant byte of E (E+2), the X-REG is cleared,
and the Y-REG is not disturbed.
Distributed under the Creative Commons License on page 5
Page 0095 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
RTAR subroutine (continued)
Caution: If XI increments to (overflows) then an exit to
location $3F5 is taken, the 'A-REG contains the high-order
MANTl byte, Ml, and XI Is cleared. FP2, SIGN, SCR,
and the X- and Y-REG's are not disturbed.
Uses: RTLOG
Example: Prior to calling RTAR, FPl (^ontains the normalize^
value -7.
FPl
$83
$A0
XI
Ml
(-7)
After calling RTAR, FPl contains the unnormalized
value -7 (note that precision is lost off the low-order
end of Ml ) .
FPl
$84
XI
$D0
(-7)
Ml
Note: Ml sign bit is unchanged.
Distributed under the Creative Commons License on page 5
Page 0096 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
RTLOG subroutine (address $F480)
Purpose: To shift the 6-byte field MANTl and E one bit to the
right '(toward the least significant bit). The 6502
carry bit is shigted into the high-order Ml bit.
This is useful in correcting binary sura overflows.
Entry: A normalized or unnormal ized floating point value is in
FPl. Thp carry must be cleareti or set by the user
since it is shifted into the sign bit of Ml,
Exit: Same as RTAR except that the sign bit of Ml is not pre-
served (it is set to the vlaue of the carry bit on entry).
Caution: Same as RTAR.
Example: Prior to calling RTLOG, FPl conatins the normalized
value -12 and the carry is clear.
FPl:
[ $83
$A0 j
(-12)
XI
Ml
After calling RTLOG, Ml is shifted one bit to the right
and the sign bit is clear. XI is incremented by 1.
FPl:
$84
$50
XI
Ml
(+20)
Note: The bit shifted off the end of MANTl is rotated
into the high order bit of the 3-byte extension
E. The 3-byte E field is also shifted one bit
to the right.
Distributed under the Creative Commons License on page 5
Page 0097 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
RTLOGl subroutine (address $F484)
Prupose: To shift MANTl and E right one bit without adjusting
XI. This is used by teh multiply loop. The carry
is shifted into the sign bit of MANTl.
Entry: Ml and E contain a 6-byte unsigned field. E la the
3-byte low-order extension of MANTl.
Exit: Same as RTLOG except that XI is not altered and an overflow
exit cannot occur.
MD2 subroutine (address $F4E2)
Purpose: To clear the 3-byte MANTl field for FMUL and FDIV,
check for initial result exponent overflow (and
underflow), and initialize the X-REG to $17 for loop
count ing .
Entry: The X-REG is cleared by teh user since it is placed in
the 3 bytes of MANTl. The A-REG contains the result
of an exponent addition (FMUL) or subtraction (FDIV),
The carry and sign status bits should be set according
to this addition or subtraction for overflow and under-
flow determination.
Exit: The 3 bytes of Ml are cleared (or all set to the contents
of the X-REG on entry) and the Y-REG is loaded with $17,
The sign bit of the A-REG is complemented and a copy of
the A-aEG is stored in XI. FP2 , SIGN, SCR, and the X-REG
are not disturbed.
Uses: NORM.
Caution; Exponent overflow results in an exit to location $3F5,
Exponent underflow results in an early return from the
Distributed under the Creative Commons License on page 5
Page 0098 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
MD2 su b routine ( cont i nu_ed)^
calling subroutine (FDIV or FMUL) with a floating point
zero in FPl. Because MD2 pops k return address off
the stack, it may only be called by another subroutine.
Distributed under the Creative Commons License on page 5
Page 0099 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
1 : 49 p. M.
10.
r425
IS
^"426
A2
02
h 423
: B5
F9
-42A
75
F5
-42C
95
F9
-42C
CA
10
^ 7
1
60
- 432
06
F3
-434
20
37
-437
24
F9
439
10
05
-43B
20
A4
43E
E6
F3
-440
3CJ
'441
A 2
04
-'443
94
FB
445
C.5
F7
-"447
C;4
|-3
"449
94
F7
-44B
!-3
■44D
CA
'44C
DO
F3
-450
60
■451
A9
SE
-453-
'* O
1- 3
-455
A5
F9
•45 7
C9
CO
•459
:30
OC
■45B-
C6
F8
•450:
06
(-B
■/■ - 'T-
26
FA
F4
F4
/I
1
3
4
3
6
7
3
9
10
1 1
12
13
?7/
* ■»■•»■■»■■)(-«■•*■ -tHHH)- -(HI.* *******
PAGE-
*
»
«■
♦
*
♦
*
*
APPLE- 1 1 FLCiATIr^;G
PC IN I ROUriNES
COPYRIGHl 1977 BY
APPLE COMprjiER INC.
ALL RIGHlS RESERVED
S. WOZNIAK
*
»
*
*
♦
»
*
*
♦
♦
*****»**********■******#
14
TITLE
"FLOAT IN
3 PC INI
ROU FINES"
15
SIGN
EPZ
SF3
/
t
16
X2
EPZ
$F4
17
n2
EPZ
SF5
13
XI
EPZ
SF3
19
Ml
EPZ
5F9
20
E
EPZ
SFC
(
21
OVLGC
EQIJ
S.3F5
ORG
SF425
23
ADD
CLC
CLEAR CARRY.
24
LDX
*fS2
INDEX FOR 3 -EYTb ADD. '
25
ADD I
LDA
Ml, X
26
ADC
M2, X
ADD A EYft OF MAN 1 2 TO MANfl.,-
27
STA
Ml, X
23
DEX
INLiEX TO NhXT MORE SIGNIF. BY 1
29
EPL
ADDl
LOOP UNl'IL DONE.
30
RTS
RETU;?N '
31
MLil
ASL
S I GN
CLEAR LSB OF SIGN.
32
JSR
AESWAP
ABS VAL OF Ml, THEN SWAP WITH
33
ABSWAP
BIT
Ml
MAN 1 1 NEGATIVE?
34
EPL
ABSWAP 1
NO, SWAP WITH MANI2 AND RETUKK
35
JSiR
FCOMPL
YES, COMPLEMENT IT.
36
INC
SIGN
I NCR SIGN. COM.-LEMENI ING LSB.^
37
ABSWAPl
SEC
SEI CARRY FOR RETUKN TO MiJL/OI
33
SWAP
LDX
#$4
INDEX FOR 4-EYrE SWAP.
39
SWAPl
STY
E-1, X
V
40
LDA
Xl-1, X
SWAP A BY IE OF EXP..'MAN) 1 WITH
41
LDY
X2-1, X
EXP./MANr2 AND LEAVE A COPY Of^.
0.2
STY
Xl-1, X
MAN 11 IN E (3 BYlES). E-t-3 USw
A3
STA
X2-1, X
44
DEX
ADVAi-JCE INLiEX TO NEXT BYTE.
45
ENh"
SWAPl
LOOP UNTIL DONE. <
^6
RTS
RETURN
A7
FluAT
LDA
^fSSE
INIT EXPl TO 14,
■as
STA
XI
THEN NORMALIZE TO FLOAT. C
49
NGRMl
LDA
Ml
HIGH-ORDER MANI 1 BYTE.
50
CMP
»*C0
UPPER TWO BITS UNEQUAL'^
51
BMI
RTSl
YES. RETURN WITH MAN 1 1 NORMAL.
52
DEC
XI
DECREMENT EXPl.
53
ASL
Ml-^2
54
POL
Ml+1
SHIFT MANTl (3 BYTES) LEFT. '<
Distributed under the Creative Commons License on page 5
Page 0100 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
FLCA T I NO PC I rj I SCiU 1' I N'tS
49 F
M, .
10/3/1977
26
F9
ROL
Ml
A3
F3
56
NORM
LDA
X 1
DO
Et
57
BrJC
NORM I
^1^. .
60
(TO
RTSl
RTS
20
A4 F4
59
FSIJb
■JSR
FCOMPL
^6b:
20
7B F4
60
SWHALCN
.J3R
ALGNSWP
U,.E:
A^
F4
61
F"ADD
LDA
X2
*70:
C5
FS
62
CMP
XI
172:
DO
F7
63
ENt£
SWKALGN
v74:
20
25 F4
64
..ISR
ADD
:>77;
50
EA
65
ADDEND
EVC
fJCRM
\79:
70
05
66
EVS
RTLOG
♦ 7B:
90
C4
67
ALGrJSWF
ECC
SWAP
63
♦
ELSE SHIFT RIGIl
\7D:
A 5
F9
69
RTAR
M 1
n X
;7F:
OA
70
:n::0 ;
£6
F3
71
RTLOij
Y 1
A 1
io2:
FO
75
72
1 J V r L-
ViA:
A2
FA
73
RTLOGl
LUX
-1+ 1 C A
76
FF
74
RORl
C t~i Ci
C-TsM A
V.'JQ:
E;3
75
T h f y
*S9:
DO
FB
76
*SB:
60
77
*SC;
20
32 F4
73
FMUL
tJoK
Ntn 1
*SF:
65
FS
79
Aril"
Y 1
A X
20
E2 F4
30
•JoK
M \'\ '"f
^94:
13
31
CLC
20
34 F4
'P,'Z
MULl
•-'--•rv
RTLQG 1
90
03
33
20
25 F4
34
n u u
49D:
i3
;55
MUU2
49E :
10
\ 5
36
P PI
4A0:
46
r 3
37
flOENU
LSR
SIGN
4A2:
90
EF
NORMX
ECC
NORM .
4A4:
;:-is
39
FCOMPL
:BEC
4A.5:
A2
03
90
LDX
#*3
4A7;
A9
00
91
COMPL I
LDA
#S0
4Av
F3
r3
92
SEC
XI. X
4AE!;
FS
93
STA
XI, X
4 AD;
CA
94
DEX
4AE:
DO
F7
95
ENE
COMPLl
4t;0:
FO
C5
96
EEQ
ADDEND
4E:2:
20
32 F4
97
FDIV
.JSR
MDl
4E5:
£t-
F3
9'3
SBC
XI
4B7.
20
E2 F4
99
JCR
MD2
4EA;
3S
100
DWl
SEC
4E:B;
A2
02
101
LDX
#*2
■4bD'
BZ
F5
102
DIV2
LDA
M2. X
4bF
F3
f"C
103
SEC
E, X
•4C1 ;
43
104
PHA
A'C'2'
CA
105
DEX
"4l:3.
10
FS
106
EPL
DIV2
~(
FD
107
LDX
*»4FD
7
63
lOS
DIV3
PLA
PAGE: 2
EXPl 2ER0?
rjo, coNriNut normalizing.
RTS RETURN.
CMPL MANll, CLEARS CARRT UNLESS
RIGHT, SHIFT MANTl OR SWAP WI'i..
COMPARE EXPl WITH EXP2.
IF #, SWAP ADDENOC OR ALIGN MA„,r
ADD ALIGNED MANIISSAS.
NO nVERFLQW, NORMALIZE RESULT
OV: SHIFT Ml RIGIl I, CARRY INio
.SWAP IF CARRY CLEAR. , .
ARITH.
SIGN MANfl INIO CARRY FOR
RIGHf ARITH SHIFT.
I NCR XI TO ADJUST FOR RICHf SHI
EXPl our OF RANGE.
INDEX FOR 6: BYTE RIGHT SHIFT.
NEXT BYTE OF SHIFT.
LOOP UNTIL DONE.
RETURN.
ABS VAL OF MANTl, MAN 1 2.
ADD EXPl TO EXP2 FOR PRODUCT EX
CHECK PROD. EXP AND PREP. FOP f
CLEAR CARRY FOR FIRST SIT.
Ml AND E RIGHT (PROD AND MPLIEH
IF CARRY CLEAR, SKIP PARTIAL PF
ADD MULTIPLICAND TO PRODUCT.
NCXT MUL ITERATION.
LOOP UN I IL DONE.
TEST SIGN LSB.
IF EVEN, NORMALIZE PROD, ELSE CX
SEf CARRY FOR SUBTRACT.
INUCX FOR S-EYTE SUBTRACT.
CLEAR A.
SUBTRACT BYTE OF EXPl.
RESTORE IT.
NEXT MORE SIGNIFICANl BYTE.
LOOP UNTIL DONE.
NORMALIZE (OR SHIFT RT IF OVF^
TAKE ABS VAL OF MANTl, MANr2.
SHETRACT EXPl FROM EXP2.
SAVE AS QUOTIENT EXP.
SET CARRY FOR SUBTRACT.
INDEX FOR 3-BYlE SUBTRACTION.
SUBTRACT A BYTE OF E FROM MANi
SAVE ON STACK.
NEXT MORE SIGNIFICANT BY 1 E.
LOOP UN 1 IL DONE,
INDEX FOR .3-BYrE CONDITIONAL Mi
PULL BYTE OF DIFFERENCE OFF . .
Distributed under the Creative Commons License on page 5
Page 0101 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
t:c< F
ji.'ji .'^ijij r I f.;L£S
1 .
P M.
, 10/3/1977
PAGE 3
F4::;;Ec
90
02
109
BCC
DIV4
IF M2<h' THEN DON-T RESTORE M2
,-4:: A;
95
r" y
110
STA
n2+3. X
F4CC:
£3
1 1 1
DIV4
I NX
NEXT LESS SIGNIFICANf BYTE.
0:
DO
i 8
112
EfJE
D I V3
LOOP UNl'IL DONE.
H'^.^F :
26
FB
113
ROL
F4D1 :
26
FA
114
ROL
Ml + l
ROLL QUOTICNf LEFT, CARRY IN If..
F4D.-3:
26
T9
115
'rql
Ml
I-4D5:
06
H7
1 16
A3L
M2+2
F4D7:
26
F/:>
117
ROL
n2-i-l
SHIFT DIVIDEND LEFT.
f 4D'?:
26
F5
1 IS
RQL
M2 ■
F4DB;
EO
IC
119
C-ii::S
OVFL
OVFL IS DUE TO UrJrJGRMEO Dl^ISr
r4DD:
SQ
120
DEY
NEXT DIVIDE ITERATION.
F4DE:
DO
DA
121
BfJL
DIVl
LOOP UNlIL DONE 23 ITEkATICNS
F4E0:
FO
BE
122
BEQ
MUENO
NORM. QIJOTIENI AND CORRECT SI''
F4C2;
S6.
KB
123
nD2
^3TX
NH-2
F4L4:
156
i^A
124
SIX
MH-1
CLEAR MANTl (3 BYTES) FOR MUL;
F4e6;
156
F9
125
SIX
Ml
-4!l:3;
BO
OD
126
BCS
OVCHK
IF CALC. SET CARRY, CHECK FOR .
-4EA;
30
04
127
EMI
MD3
IF NEG THEN NO UNUERFLOW.
-4l-r;:
68
123
PLA
POP ONE RETURN LEVEL.
^4[:D:
6:3
129
PLA
■ 4!li::
90
B2
130
BCC
NORMX
CLEAR XI ANU RE f URN,
■4r0;
49
30
131
MU3
EOR
#*30
CGMPLEMENI SIGN BIT OF EXPONfc^
'4F2:
FS
132
STA
XI
STQTiE IT.
-41-4:
AO
17
1 33
LDY
#*17
COUNI 24 MUL./23 DIV ITERATIONS
-4F6:
60
134
RTS
RETURN.
-41-/:
10
F7
1 35
OVCHK
BPL
MD3
IF POSITIVE EXP THEN NO OVFL.
-4F9:
4C
F5
03 136
137
OVFL
.-IMP
ORG
OVLOC
$F63D
. J:
20
70
F4 13.3
FIX!
■JSR
RTAR
-'640:
A5
f-S
1 39
FIX
LDA
XI
-642:
10
13
140
BPL
UNDFL
-644:
C9
SE
141
CHP
#3SE
"646:
DO
F5
142
BNE
FIXl
64,9:
24
F9
143
BIT
Ml
'64 A:
10
OA
144
BPL
FIXRTS
•64C:
A5
FB
145
LDA
MH-2
■64C:
FO
06
146
BEQ
FIXRTS
'650:
E6
I'A
147
INC
Ml-i-1
"652-
DO
02
143
BNl£
FIXRTS
'654:
E6
F9
149
INC
Ml
'6 "1.6:
60
150
HXRTS
RTS
RTS
"657:
A 9
00
151
Ur^LiFL
LDA
feSO
'659:
S5
F9
152
STA
Ml
■6!:il3:
;35
FA
1 53
STA
Ml-t-l
65D:
60
154
RTS
-* X *:r.L
CCE
ssruL AS
SEf1L-;LY: tiO
ERRi:
RS
Distributed under the Creative Commons License on page 5
Page 0102 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
CRODS-REh CKNCE: FLOATING POIWl KOIJIINtS
AbCU'AP
F437
0032
AR-.WAPl
\ 440
0034
ADD
r425
0064
ADDl
r42;3
0029
ADDLfJO
F477
0096
ALGNSWP
l"47B
0060
COr^PL 1
f 4A7
0095
UIVl
I-4BA
0121
DIV2
F4C:D
0106
r4C7
01 12
D1V4
r4CC
0109
L
OOFC < Z )
0039
FADD
i 46E
i'COMPL
F4A4
0035
FOIV
r4B2
1 IX ,
F640
FIXl
I-63D
0142
riXRTS
0144
FLOAT
r451
rnuL
F4SC
F 463
Ml
00F9( Z>
0025
M2
00F5<Z)
MOl
F432
MD2
F4E2
riD3
r4F0
MLiLND
F4A0
MULl
F495
MU! 2
F49D
NOrvM
F463
fJOrXM 1
F455
N'ur^MX
I-4A2
OVCHK
r4F7
OVFL
F4F9
OVLOC
03F5
Ri:if;i
F436
RTAR
I 47D
fv'TLOG
F4yO
HI LOGl
l"434
K' l 31
F467
S I GN
00F3( 2 )
SUJAP
r441
SWAPl
F'443
3WPALGN
F46E
UrJLiFL
F657
XI
OOFS( Z )
X2
00F4
0123
0026
00 7 S
0030
0127
0122
00C6
0033
0065
0057
0130
0126
0072
0136
0076
0133
0066
00S2
OObl
0031
0067
0045
0063
0140
0040
0132
0041
0027
0124
0102
0097
0099
0135
0093
01 19
0033
0125
0110
0049
0143
0116
0053 0054
0145 0147
0117 0113
0055
0149
0069
0152
01 13
0153
0114 OllS
0036 0037
0042
0139
0043
004S 0052 0056 0062 0071 0079 0092 0093 0093
0061
Distributed under the Creative Commons License on page 5
Page 0103 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0104 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Apple- II
Sweet-16 -- The 6502 Dream Machine
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0105 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0106 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
SWEETie - THE 6502 DREAM MACHINE
While writing APPLE BASIC for a 6502 microprocessor I
repeatedly encountered a variant of MURPHY'S LAW. Briefly
stated, any routine operating on 16-bit data will require at
least twice the code that it should. Programs making extensive
use of 16-bit pointers (such as compilers, editors, and assemblers)
are included in this category. In my case, even th^ addition
of a few double-byte instructions to the 6502 would have only
slightly alleviated the problem. What I really needed was a
6502/RCA 1800 hybrid - a powerful 8-bit data handler complemented
by an easy to use processor with an abundance of 16-bit registers
and excellent pointer capability. My solution was to implement
a non-existent (raeta) 16-bit processor in software, interpreter
style, which I call SWEET16.
SWEET16 is based around sixteen 16-bit registers (R0-R15),
actually 32 memory locations. RO doubles as the SWEET16 accu-
mulator (ACC), R15 as the program counter (PC), and R14 as the
status register. R13 holds compare instruction results and R12
is the subroutine return stack pointer if SWEET16 subroutines
are used. All other SWEET16 registers are at the user's unre-
stricted disposal.
SWEET16 instructions fall into register and non-register
categories. The register ops specify one of the sixteen reg-
isters to be used as either a data element or a pointer to
Distributed under the Creative Commons License on page 5 I Page 01 07 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
data in memory depending on the specific instruction. For example,
INR R5 uses R5 as data and ST @H7 uses R7 as a pointer to data
in memory. , Except for the SET .instruction , register, ops take
1 byte of code each. The non-register ops are primarily 6502
style branches with the second byte specifying a ^127 byte dis-
placement relative to the address of the following instruction.
Providing that the prior register op result roeeta a specified
i
branch condition, the displacement is added to SWEET16's PC,
effecting a branch.
SWEET16 is intended as a 6502 enhancement package, not a
stand-alone processor. A 6502 program switches to SWEET16 mode
with a subroutine call and subsequent code is interpreted as
SWEET16 instructions. The non-register op RTN returns the user
program to 6502 mode after restoring the internal register
contents (A, X, Y, P, and S). The following example illustrates
how to use SWEET16.
300
B9
00
02
LDA
IN,Y
Get a char.
303
C9
CD
CMP
"M"
"M" for move?
305
DO
09
BNE
NOMOVE
No, skip move.
307
20
89
F6
JSR
SW16
Yes, call SWEET16.
30A
41
MLOOP LD
@R1
Rl holds source address
30B
52
ST
@R2
R2 holds dest . address.
30C
F3
DCR
R3
Decrement length.
30D
07
FB
BNZ
MLOOP
Loop until done.
30F
00
RTN
Return to 6502 mode.
310
C9
C5
NOMOVE CMP
"E"
"E" char?
312
DO
13
BEQ
EXIT
Yes, exit.
314
C8
I NY
No, continue
NOTE: Registers A, X, Y, P, and S are
not disturbed by SWEET16.
Distributed under the Creative Commons License on page 5
Page 0108 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
INSTRUCTION DESCRIPTIONS
The SWEET16 opcode list is short and uncomplicated.
Excepting relative branch displacements, hand assembly is
trivial. All register opcodes are formed by combining two
hex digits, one for the opcode and one to specify a register.
For example, opcodes 15 and 45 both specify register R5 while
codes 23, 27 and 29 are all ST ops. Most register ops are
assigned in complementary pairs to facilitate remembering
them. Thus LD and ST are opcodes 2n and 3n respectively, while
LD @ and ST @ are codes 4n and 5n .
Opcodes to C (hex) are assigned to the thirteen
non-register ops. Except for RTN (opcode 0), BK (OA), and
RS (B), the non-register ops are 6502 style relative branches.
The second byte of a branch instruction contains a *127 byte
displacement value (in two's complement form) relative to the
address of the instruction immediately following the branch.
If a specified branch condition is met by the prior register
op result, the displacement is added to the PC effecting a
branch. Except for BR (Branch always) and BS (Branch to Sub-
routine), the branch opcodes are assigned in complementary
pairs, rendering them easily remembered for hand coding. For
example, Branch if Plus and Branch if Minus are opcodes 4 and
5 while Branch if Zero and Branch if NonZero are opcodes 6 and 7.
Distributed under the Creative Commons License on page 5
Page 0109 of 0213
The Woz Wonderbook -- 1977 --
DigiBarn Computer Museum
>
-- Steve Wozniak, Apple Computer Inc.
, — 1
(U
G
^ — s
■H
CD
^ ^
U)
4->
q
1— '
■ H
, — , (
/-I
w
rH G
-p
OJ ^ '-^
•H
3
CO
tl)
CO ^
A."
Q
1^ V — . r i_i
("1
3
G /A t_.i
r.
w
I— «
M
t>> cd
rH
•H
ni
U/
3
rvi m4 r ^
CN TO ^
(-M
L>J
CO
— s
' — \
r — s
(0
Q
t3
t3
lO rH *H
SH
4h
Vi
^ SH
<D
(D
(U
■H
■H
•H
•H -H
-p
G
h£)
G
hi)
G
tifi
H
r^ f C""
(-3
j3
_rj
-C
^ ^
'— - G
X3
•rH
•H
•H
■M
+J CJ o o
CJ
u
cn
0)
CO
f ("* f
C
G
G C
pj 3
(3
U3
(0
^
(-U
cd
cd oi
CD +J
d
•H
Fh Jh Sh
H
H
H M
CD
c
d
G
hi)
p-H T'f\ rf\
UU W
rf\
M-l
l-H I-H
CQ «
m
<U
!-i
CD
1
o:
<A
C
■•^
o
oi
oi
lA
ni
cij 0)
Iz;
O <D
a)
H
H S
M w
CO
H tt! !2; o
Cs)
cQ oa
CQ
CQ
CQ
a 03
PQ
O H CNl CO
CO
[>
00
<; m
Q
W
- — 1
o o o o
CO
Ph
Q
O
o
CD
i-H
E-<
W
^ — s
\^
cu
M
*H
(D
■rH
LJ
^
r — V
4-'
*rH
■H
(D
+-> C3
•H
d)
M
CD
, f
-H
H
*H
rH
_Q
CD
<D
. — s
f — s
•H
G
^ O1
rH
+->
■P
G
Id
■H
^
^ — \
G
G
a
•H
XJ
■a ft
3
(D
0)
0)
•H
a
^^
a
s
C ^ 0)
OJ
<D
•H 0)
T3
CD
t,
M
u
ft
U
u
+-> cii O
f— 1
<A
Q
n,
ft
g
[/) C -P
■p
-P
-P
3
c
<D
W
►J
CO
<; CO
ft
o
Q
o<
u
o
u
C fl c
c
G
C
G
a c
G G
G
G
G
G
0)
QJ Cci K
P5
cu 03
03 D3
03
p3
03
03
•p
@
@
©
© @
(S)
t/}
-H
Q
03
fcJD
Q
Q
ft ft
Q a
ft
«
03
W Q H
Q
H
Q
H
Q P
ft
U
w J w
W
CQ
ft CO
< CO
ft
u
M
Q
CCS
a
G
a
G
G G
G a
c
G
G
G
rH CM n
CD
< m
u
P
W
1*1
Distributed under tine Creative Commons License on page 5
1 Page 0110 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
REGISTER OPS
SET Rn, Constant
In \' lowj , high
constant
(Set)
The 2-byte constant is loaded into Rn (n = to F. hex)
d branch conditions set accordingly. The carry is
an
cleared.
Exam£le
15 34 AO
SET
R5,A034 R5 now contains A034
LD Rn
The ACC (RO) is loaded from Rn and branch condition,
set according to the data transferred. The carry is
cleared and the contents of Rn are not disturbed.
Example
, c 04 AO SET R5, A034
^ LD R5 ACC now contains A034
ST Rn
3n
ACC is stored into Rn an
o.Cing to the data transferred. The carry 1= beared
The
ace
and the ACC contents are not disturbed.
Example
(Store)
d branch conditions set
25
36
LD R5
ST R6
Copy the contents
of R5 to R6.
Distributed under the Creative Commons License on page 5 I Page 0111 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
1 „ ■ (Load indirect)
LD (S-Rn
The low-order ACC b^e is loaded from the momory location
whose address resides in Rn and the high-order ACC byte is
cleared. Branch conditions reflect the final ACC con-
tents which will always be positive and never minus 1.
The carry is cleared. After the transfer. Rn is incre-
mented by 1.
Example
15 34 AO SET R5,A034
rn ©RS ACC is loaded from
45 Memory location A034
and R5 is incremented
to A035.
ST @Rn
r "'j (Store indirect)
The low-order ACC by't^Is stored into the memory location
.hose address resides in Rn . Branch conditions reflect
the 2-byte ACC contents. The carry is cleared. After
the transfer, Rn is incremented by 1.
Example
15 34 AO SET R5 , A034 Load pointers R5 and R6
Ig 22 90 SET R6, 9022 with A034 and 9022.
LD @R5 Move a byte from lo^f
45 ^Q34 to location 9022.
ST @R6 Both pointers are
incremented.
Distributed under the Creative Commons License on page 5 I Page 01 1 2 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
ruRn I _ ^^oad double-byte indirect)
The low order ACC byte is loaded from the memory location
whose address resides in Rn and Rn is then incremented
by 1. The high order ACC byte is loaded from the memory
location whose address resides in the (incremented) Rn
and Rn is again incremented by 1. Branch conditions
reflect the final ACC contents. The carry is cleared.
E xample
15 34 AO SET R5, A034
LDD @R5 The low-order ACC byte
is loaded from location
A034, the high-order byte
from location A035. B5 Is
incremented to A036.
STD @Rn
i 7n i (Store double-byte indirect)
The low-order ACC byte is stored into the memory location
whose address resides in Rn and Rn is then incremented
by 1. The high-order ACC byte is stored into the memory
location whose address resides in (the incremented) Rn
and Rn is again incremented by 1. Branch conditions
reflect the ACC contents which are not disturbed. The
carry is cleared.
Example
15 34 AO SET R5, A034 Load pointers R5 and R6
16 22 90 SET R6, 9022 with A034 and 9022. Move
g5 LDD @R5 double byte from locations
STD @R6 A034 and A035 to locations
9022 and 9023. Both point-
ers are incremented by 2.
Distributed under the Creative Commons License on page 5 I Page 01 1 3 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
POP aRn j 8n (Pop indirect)
The low order ACC byte is loaded from the memory location
whose address resides in Rn after Rn is decremented by 1
and the high order ACC byte is cleared. Branch conditions
reflect the final 2-byte ACC contents which will always be
positive and never minus 1. The carry is cleared. Because
Rn is decremented prior to loading the ACC, single byte
stacks may be implemented with the ST @Rn and POP @Rn
ops (Rn is the stack pointer).
Example
15 34 AO SET R5, A034 Init stack pointer.
10 04 00 SET RO, 4 Load 4 into ACC.
35 ST @R5 Push 4 onto stack.
10 05 00 SET RO, 5 Load 5 into ACC.
35 ST @R5 Push 5 onto stack,
10 06 00 SET RO, 6 Load 6 into ACC.
35 ST @R5 Push 6 onto stack.
85 POP @R5 Pop 6 off stack into ACC.
85 POP @R5 Pop 5 off stack.
85 POP @R5 Pop 4 off stack.
Distributed under the Creative Commons License on page 5 I Page 01 1 4 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
' ■ *
STP ciRn ; 9n ■ (STORE POP indirect)
i
The low oi-der ACC byte is stored into the memory location
whose address resides in Rn after Rn is decremented by 1.
Then the high-order ACC byte is stored into the memory
location whose address resides in Rn after Rn is again
decremented by 1. Branch conditions will reflect the
2-byte ACC contents which are not modified. STP @Rn
and FOP @Rn are used together to move data blocks
beginning at the greatest address and working down.
Additionally, single-byte stacks may be implemented
with the STP @Rn and LDA @Rn ops.
Example
14 34 AO SET R4, A034 Init pointers.
15 22 90 SET R5, 9022
84 POP @R4 Move byte from A033
95 STP @R5 to 9021.
84 POP @R4 Move byte from A032
95 STP @R5 to 9020.
Distributed under the Creative Commons License on page 5
Page 0115 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
ADD Rn
! An
(Add)
The contents of Rn are addftd to the contents of the ACC
(RO) and the low-order 16 bits of the sum restored in
ACC. The 17th sum bit becomes the carry and other branch
conditions reflect the final ACC contents.
Example
10 34 76
SET RO, 7634 Init RQ (ACC)
11 27 42
SET Rl. 4 227
and Rl.
Al
AO
ADD Rl
ADD RO
Add Rl (sum = B85B,
carry clear)
Double ACC (RO) to 70B6
with carry set.
Distributed under the Creative Commons License on page 5
Page 0116 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
SUB Rn Bn (Subtract)
The contents of Rn are subtracted from the ACC contents
by pesrforraing a two's complement addition:
ACC ACC + Rn + 1
The low order 16 bits of the subtraction are restored
i
in the ACC. The 17th sum bit becomes the carry and other
branch conditions reflect the final ACC contents. If
the 16-bit unsigned ACC contents are greater than or
equal to the 16-bit unsigned Rn contents then the
carry is set, otherwise it is cleared. Rn is not disturbed.
Example
10 34 76 SET RO , 7634 Init RO (ACC)
11 27 42 SET Rl, 4227 and Rl .
Al SUB Rl Subtract Rl (diff =
340D with carry set)
AO SUB RO Clears ACC (RO)
Distributed under the Creative Commons License on page 5 I Page 01 1 7 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
POPD @Rn I Cn j (POP Double-byte indirect)
Rn is decremented by 1 and the high-order ACC byte is
loaded from the memory location whose address now reaide's
in Rn. Then Rn is again decremented by 1 and the low-order
ACC byte is loaded from the corresponding memory location.
Branch conditions reflect the final ACC contents. The
carry is cleared. Because Rn is decremented prior to
loading each of the ACC halves, double-byte stacks
may be implemented with the STD @Rn and POPD @Rn ops
(Rn is the stack pointer).
Example
15 34 AO SET R5, A034 Init stack pointer.
10 12 AA SET RO, AA12 Load AA12 into ACC.
75 STD @R5 Push AA12 onto stack.
10 34 BE SET RO. BB34 Load BB34 into ACC.
75 STD @R5 Push BB34 onto stack,
10 56 CC SET RO, CC56 Load CC56 into ACC.
C5 POPD @R5 Pop CC56 off stack.
C5 POPD @R5 Pop BB34 off stack.
C5 POPD @R5 Pop AA12 off stack.
Distributed under the Creative Commons License on page 5 I Page 01 1 8 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
CPR Rn I Dn ' (Compare)
The ACC (RO) contents are compared to Rn by performing
the 16-bit binary subtraction ACC-Rn and storing the low
order 16 difference bits in R13 for subsequent' branch
tests. If the 16-bit unsigned ACC contents are greater
than or equal to the 16-bit unsigned Rn contents then
the carry is set, otherwise it is cleared. No other
registers, including ACC and Rn, are disturbed.
Example
15 34 AO SET R5 , A034 Pointer to memory.
16 BF AO SET R6 , AOBF Limit address.
10 00 00 LOOP SET RO, Zero data.
75 STD @R5 Clear 2 Iocs, incr R5 by 2
25 LD R5 Compare pointer R5
D6 CPR R6 to limit R6 ,
02 F8 BNC LOOP Loop If carry clear.
Distributed under the Creative Commons License on page 5 I Page 01 1 9 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
INR Rn ^ En I (Increment)
The contents of Rn are incremented by 1. The carry is
cleared and other branch conditions reflect the incre-
mented value.
Example
15 34 AO SET R5, A034 Init R5 (pointer)
10 00 00 SET RO, Zero to RO.
55 ST @R5 ciears loc A034 and incrs
R5 to A035.
E5 INR R5 Incr R5 to A036
55 ST @R5 Clears loc A036 (not A035)
DCR Rn i Fn
(Decrement )
The contents of Rn are decremented by 1. The carry is
cleared and other branch conditions reflect the decre-
mented value.
Example (Clear 9 bytes beginning at loc A034)
15 34 AO SET R5, A034 Init pointer.
14 09 00 SET R4, 9 Init count.
10 00 00 SET RO, Zero ACC.
55 LOOP ST @R5 Clear a mem byte.
F4 DCR R4 Deer, count.
07 FC BNZ LOOP Loop until zero.
Distributed under the Creative Commons License on page 5 I Page 01 20 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
NON-REGISTER INSTRUCTIONS
j^^j^ I 00 1 (Return to 6502 mode)
Control is returned to the 6502 and program execution
continues at the location immediately following the RTN
instruction. The 6502 registers and status conditions
are restored to their original contents (prior entering
SWEET16 mode)
ea [ Ol] [d^ (Branch Always)
An effective address (ea) is calculated by adding the
signed displacement byte (d) to the PC. The PC contains
the address of the instruction immediately following
the BR, or the address of the BR op plus 2. The
displacement is a signed twos complement value from
-128 to +127. Branch conditions are not changed. Note
that effective address calculation is identical to that
for 6502 relative branches. The hex add and subtract
features of the APPLE-II monitor may be used to calculate
displacements .
d = $80 ea = PC + 2 - 128
d = $81 ea = PC + 2 - 127
d = $FF ea = PC + 2 - 1
d = $00 ea = PC + 2 +
d = $01 ea = PC + 2 + 1
d = $7E ea = PC + 2 + 126
d = $7F ea = PC + 2 + 127
Exampl e
$300: 01 50 BR $352
Distributed under the Creative Commons License on page 5
Page 0121 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
BNC ea | 02 I d (Branch if No Carry)
A branch to the effective address is taken only if the
carry is clear, otherwise execution resumes as normal
with the next instruction. Branch conditions are not
changed .
"~ — I I ^
BC ea 03 ' d (Branch if Carry set)
A branch is effected only if the carry is set^. Branch
conditions are not changed.
BP ea
04 I d
(Branch if Plus)
A branch is effected only if the prior 'result' (or most
recently transferred data) was positive. Branch con-
ditions are not changed.
Example (Clear mem from loc. A034 to A03F)
15 34 AO
14 3F AD
10 00 00
55
24
D5
04 F8
SET R5, A034 Init pointer.
SET R4, A03F Init limit.
LOOP SET RO,
ST @R5 Clear mem byte, incr R5,
LD R4 Compare limit to
CPR R5 pointer.
BP
LOOP
Loop until done.
BM ea 05 d i (Branch if Minus)
A branch is effected only if the prior 'result' was
minus (negative, MSB = 1). Branch conditions are not
changed .
Distributed under the Creative Commons License on page 5
Page 0122 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
■ 1 , — -I
BZ ea ^ 06 j I d (Branch if Zero)
A branch is effected only if the prior 'result' was zero.
Branch conditions are not changed.
(Branch if NonZero)
BNZ ea | OtJ j d
A branch is effected only if the prior 'result' was
non-zero. Branch conditions are not changed.
BMl ea
081
d ~| (Branch if Minus 1)
A branch is effected only if the prior 'result' was
minus 1 ( $FFFF hex). Branch conditions are not changed,
BNMl ea 09 ■ d ; (Branch if Not Minus 1)
A branch is effected only if the prior 'result' was not
minus 1 ( $FFFF hex). Branch conditions are not changed.
BRK
OA I (Break)
A 6502 BRK (break) instruction is executed. SWEET16
may be reentered nondestructively at SW16D after correcting
the stack pointer to its value prior executing the BRK.
Distributed under the Creative Commons License on page 5
Page 0123 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
RS
OB ■ (Return from SWEET16 Subroutine)
RS terminates execution of a SWEET16 subroutine and
returns to the SWEET16 .calling program which , resumes
execution (in SWEET16 mode). R12, which is the SWEET16
subroutine return stack pointer, is decremented twice.
Branch conditions are not changed.
BS ea
OC
P d | (Branch to SWEET16 Subroutine)
A branch to the effective address (PC + 2 + d) is taken
and execution is resumed in SWEET16 mode. The current
PC is pushed onto a ' S\VEET16 subroutine return address'
stack whose pointer is R12, and R12 is incremented by
2. The carry is cleared and branch conditions set to
indicate the current ACC contents.
Example (Calling a 'memory move' subroutine to move
A034-A03B to 3000-3007)
300 ;
15
34
AO
SET
R5, A034
Init pointer 1,
303:
14
3B
AO
SET
R4, A03B
Init limit 1.
306 :
16
00
30
SET
R6, 3000
Init pointer 2.
309:
OC
15
BS
MOVE
Call move subroutine
320:
45
MOVE LD
@R5
Move one
321 :
56
ST
@R6
byte .
322 :
24
LD
R4
323 :
D4
CPR
R5
Test if done.
324 :
04
FA
BP
MOVE
Return .
326 :
OB
RS
Distributed under the Creative Commons License on page 5 I Page 01 24 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
THEORY OF OPERATION
SWEET16 execution mode begins with a subroutine call to
SW16. The user must insure that the 6502 is in hex mode upon
entry. All 6502 registers are saved at this time, to be re-
stored when a SWEET16 RTN instruction returns control to the
6502. If you can tolerate indefinite 6502 register contents
upon exit, approximately 30 usee may be saved by entering at
SW16 + 3, Because this might cause an inadvertant switch from
hex to decimal mode, it is advisable to enter at SW16 the first
time through.
After saving the 6502 registers, SWEET16 initializes
its PC (R15) with the subroutine return address off the 6502
stack. SWEET16's PC points to the location preceding the next
instruction to be executed. Following the subroutine call
are 1-, 2-, and 3-byte SWEET16 instructions, stored in ascending
memory locations like 6502 instructions. The main loop at SW16B
repeatedly calls the 'execute instruction' routine at SW16C
which examines one opcode for type and branches to the appro-
priate subroutine to execute it.
Subroutine SW16C increments the PC (R15) and fetches the
next opcode which is either a register op of the form OP REG
with OP between 1 and 15 or a non-register op of the form OP
with OP between and 13. Assuming a register op, the register
specification is doubled to account for the 2-byte SWEET16
registers and placed in the X-Reg for indexing. Then the
instruction type is determined. Register ops place the doubled
register specification in the high order byte of R14 indicating
Distributed under the Creative Commons License on page 5
Page 0125 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
the 'prior result register' to subsequent branch instructions.
Non-register ops treat the register specification (right-hand
half-byte) as their opcode, increment the SWEET16 PC to point -
at the displacement byte of branch instructions, load the A-Heg
with the 'prior result register' index for branch condition
testing, and clear the Y-Reg.
WHEN IS AN RTS REALLY A JSR?
Each instruction type has a corresponding subroutine.
The subroutine entry points are stored in a table which is
directly indexed into by the opcode. By assigning all the
entries to a common page only a single byte of address need
be stored per routine. The 6502 indirect jump might have been
used as follows to transfer control to the appropriate subroutine.
LDA #ADRH High-order address byte.
STA IND+1
LDA OPTBL.X Low-order byte.
STA IND
JMP (IND)
To save code the subroutine entry address (minusll)
is pushed onto the stack, high-order byte first. A 6502 RTS
(ReTurn from Subroutine) is used to pop the address off the
stack and into the 6502 PC (after incrementing by 1). The
net result is that the desired subroutine is reached by executing
a subroutine return instruction!
Distributed under the Creative Commons License on page 5
Page 0126 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
OPCODE SUBROUTINES
.e.iste. op routines ™a.e use t.e e.02 ■ ze.o
,.,e ,nae.ea ..X. an. ' inae.ea X i„ai.eeV aaa.e.s-
^^^^ - - — "r:::::::--
i + < of most register ops is lezx.
The 'result of most instructions
. .nd can be sensed by subsequent branch
. s.ec..e..on . ..ea . ..e ..-o.ae^
" , .peeinc.io„ is Cansea .o i„aioa.e HO
r:::::! i.«.c.o„s .a cp, .o...,
9 to account for the 2-byte
result re.ister^ inaex t^^es 2 «
S^BTXe registers ana t.us ... LSB is .e.o. H »
ep„ instructions generate carries, t.en t.is ina.x is
mented, setting the LSB. ^i^kinE up
,r,^r>+c: the PC twice, picKing u^j
... - — r 1 ...oraance »it. a.C.
■ - e preceaes t.e U.^-oraer
convention, the lo.-oraer aata byte P
Host S«E.Ti. nonre.ister ops are relative .ranc.es
correspo„a.n. subroutines aeter„ine ,.etber or not t e
resuit. „eets tbe speci.iea branch "-"- ^YL
.be PC b, aaain. the aispiace.ent v.ue C-i3S
to +127 bytes).
Distributed under the Creative Commons License on page 5
Page 0127 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The RTN op restores the 6502 register contents, pops the
subroutine return stack and jumps indirect through the SWEETIG
PC. This transfers, control to the 6502 _ at the Instruction im-
mediately following the RTN instruction.
The BK op actually executes a 6502 break instruction (BRK),
transferring control to the interrupt handler.
Any number of subroutine levels may be implemented within
SWEET16 code via the BS (Branch to Subroutine) and RS (Return
from Subroutine) instructions. The user must initialize and
otherwise not disturb R12 if the SWEET16 subroutine capability
is used since it is utilized as the automatic subroutine return
stack pointer.
MEMORY ALLOCATION
The only storage that must be allocated for SWEET16 variables
are 32 consecutive locations in page zero for the SWEET16 regis-
ters, four locations to save the 6502 register contents, and
a few levels of the 6502 subroutine return address stack. If
you don't need to preserve the 6502 register contents, delete
the SAVE and RESTORE subroutines and the corresponding subroutine
calls. This will free the four page zero locations ASAV, XSAV,
YSAV, and PSAV.
USER MODIFICATIONS
You may wish to add some of your own instructions to this
implementation of SWEETIB. If you use the unassigned opcodes
$0E and $0F, remember that SWEET16 treats these as 2-byte instruc-
tions. You may wish to handle the break instruction as a SWEET16
call, saving two bytes of code each time you transfer into SWEET16
Distributed under the Creative Commons License on page 5
Page 0128 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
. ^ qvi^FVTie BK (Break) op as a
mode. Or you may wish to use the S\,bbilb ^
' ^ V. AT Ynu can perform absolute
■CH.AROUT' call in the interrupt handler. You can p
jumps within SWEET16 by loading teh ACC (RO) with the address
vou Wish to 3.n.p to (minus 1) and executing a ST H15 instruction.
Distributed under the Creative Commons License on page 5 I Page 01 29 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
PAGE:
P M.
-63C;
-6iJD;
1 tSF;
1 0:
I' ■b'?2:
1-695:
F69S:
F6>A
F69C:
F6'^E:
f 6A0:
h 6A1:
K6A3:
F6A5:
F6A7:
F6A:3-
F6A9
P6AA
F6AC
F6AE
FA.BO
F&hl
F6.E2
FAbS
F6B4
l-t.b7:
F6B3
' 6b9
4BB
I 6ED
10/:3/ 197/
1
:3
5
6
7
:3
9
10
11
12
13
14
15
16
17
IS
19
20
21
23
FF 24
20 4A
63
S5
IE
26
68
27
35
IF
28
20
93 F6
29
4C
92 F6
30
E6
IE
31
DO
02
E6
IF
33
A9
F/
34
43
35
AO
00
36
Bl
IE
37
29
OF
-lO
■2'
OA
39
AA
40
4A
41
51
IE
42
FO
OB
43
36
ID
44
^i.^nH^.«***«-#*^^»******•****
4A
4A
4A
AS
B9 El
4!J
60
E6 IE
DO 02
E6 IF
F6
IRF'REfEK *
*
1977 *
lER ir-c *
^■E:i.ER'v'ED *
*
[AK *
4
■SULET 1 6 I N I ERPFE TEK'
* A.-FLE-II F"
» MACHINE INTEr
*
» C:uPVHlGHr
* APPLE COr^PiJl
* ALL RIGHTS RE
*
♦
»
TITLE
ROL
Ron
R14H
K15L
R15H
S16PAG
SAVE
RESTORC
SW16
SW16E
SW16C
SW 1 60
45
46
47
43
49
50
51
53
54
TGBR
EPZ
SO
EPZ
EPZ
*1D
EPZ
siE
EPZ
slF
EQi-l
*F7
EQU
SFF4A
EGU
*FF3F
ORG
SF699
JSR
SAVE
PLA
STA
R15L
PLA
STA
R15H
JGR
JMP
INC
E;r4£
INC
LDA
PHA
LDY
LDA
AND
A3L
TAX
LSR
EOR
SW16C
sm6B
R15L
SW16D
R15H
ttS 1 6PAG
ft«0
(Rl':
tt5F
A
;l). V
A
(R15L)
BEQ
TOER
STX
R14H
LSR
A
LSR
A
LSR
A
TAY
LDA
OPTBL-
PHA
RTS
INC
R15L
BNE
T0BR2
INC
R15H
PRESERVE 6502 REG CON TENTS
IN IT SWhET16 PC
FROM RETIJ|-<N
ADDRESS .
INTERPRET ANU EXECU I E
CNtI SWEET 16 INSTR.
I NCR SWEET 16 PC FOr< FE lCH
PUSH ON STACK FOR RTS
FEiCH INSTR
MA^K REG SPECIFICATION
SSuBLE FOR 2 -BY. E REG- S
TG X-REG FOR INUEXINo
NfiW HAVE OPCODE
IF ZERO THEN NON -REb UP
INUlCATE-PRI0r< RESULT REG'
UPC0DE*2 TO LSB-S
TO Y-REG FOR INDEXING
LOW-ORDER ADR BYTE
ONiO STACK-
GOTO REG-OP RLiUriNt
I NCR PC
Distributed under the Creative Commons License on page 5
Page 0130 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
•iUlt;!::T16 INi£KrRET£R
1 ; 45
F I-;.
10/3/197/
PAGE; 2
rtEF
ED
E4
F6
55
T0ER2
LDA
ERTBL, X
LOW-ORDER ADR EY TE
I-4C2
43
56
PHA
ON 1 STACK FOR NON-REO OP
F6C:3
A5
ID
57
LDA
R14H
•'PRIOR RESULT REG' INUEX
4A
L3R
A
PREPARE CARRY FOR BC. ENC,
F6C6
60
59
RTS
GOTO NON-REG OP K'OUlINL
1- hCl
63
60
RTNZ
PLA
POP RETURN ADDRESS
FAfjtb'
63
61
PLA
F6C9
20
SF
FF
62
JSR
RESTORE
RESTORE 6502 REG COfJ TEN"! S
F 6CC
6C
IE
00
63
Jrii'
( R 1 5L )
RErur<N TO 6502 CODE VIA PC
F4.CF
81
IE
64
3E rz
LDA
( R 1 5L ) , Y
HIGH-ORDER BYTE OF CONST
K6D1
95
01
65
ST A
ROH, X
F/;.Ll3
c"3
66
DEY
t 6D4
El
IE
67
LDA
( R 1 5L ) < Y
LOW-ORDER BY Tk. OF CO.NSTAN 1'
F/-.D/5
95
00
61i
3TA
ROL, X
F6I4I13
93
69
TYA
Y-REO CONTAINS 1
F&D9
33
70
SEC
F6.UA
65
IE
71
ADC
R15L
ADD 2 TO PC
F6DC
35
IE
72
STA
R15L
K6DE
90
02
73
BCC
SE ra
F6t:o
E6
IF
74
INC
R15H
F6L2
60
75
SET2
RTS
Ft.L3
02
76
Or-'TEL
DFE
SET- 1
< IX)
r6L4
F9
77
BR TEL
DFB
RTN-1
(0)
F6I£5
04
73
DFB
LD-l
(2X )
F6E6
9D
79
DFB
ER-1
( 1 )•
F6E/
on
30
DFB
ST- 1
(3X)
F6nS
9E
31
DFB
BNC-1
(2)
F6L:9
■~/ ^
32
DFB
LDAT-1
(4X )
F6EA
AF
33
DFB
BC-1
(3)
K61£13
16
34
DFB
STAT-1
(5X )
F6EC
B2
F:5
DFB
EF-1
(4)
FALD
47
36
DFB
LDDAT-1
(6X)
f-6CE
B9
37
DFB
Bf1-1
(5)
F 6EF
51
S3
DFB
STDAT-1
(7X)
F6r-0
CO
3' 9
DFB
BZ-1
(6)
F6F1
90
DFB
PQP-1
(SX)
F6F2
l:9
91
DFB
ENZ-1
(7)
F6F3
5E
92
DFB
STPAT-1
(9X)
F 61- 4
D2
93
DFB
EMl-1
<8)
F.6KS
35
94
DFB
ADD-1
(AX)
F6!"6
DD
95
DFB
BNMl-l
(9)
F6f- ;
6E
96
DFB
SIJB-1
(BX)
F6I ;5
05
97
DFB
EK-1
(A)
F6F9
DFB
FQPB-1
(CX )
\ 6FA
E3
'?9
DFB
RS-1
(B)
F6ri3
70
100
BFE
CPR-1
(DX )
F6f-C
93
101
DFB
ES-1
<C)
F6FD
IE
102
DFE
irjR-1
(EX )
r6rE
E7
103
DFE
NUL-l
(D)
F6M"
65
104
DFB
DCR-1
(FX )
F700
E7
1 05
DFE
NUL-l
(E)
F/Ol
E7
106
DFB
NUL-l
( UNLISED )
F 702
E7
107
DFB
NUL-l
(F)
f 703
10
CA
1 OS
SET
EPL
SET Z
ALWAYS TAKEN
Distributed under the Creative Commons License on page 5
Page 0131 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
1: C5
P M.
10/3
/ 1977
PAGE: 3
r /05;
00
109
1 10
LD
EK
LDA
EOU
ROL, X
*-l
F/07
;e;5
00
1 1 1
STA
ROL
F;0'?:
&5
01
1 12
LDA
ROH, X
MOVE RX TO RO
r /OB:
C
■I J
01
113
STA.
ROH
I-/OD.
60
114
RTS
F/OE:
A =r
r-1._i
00
115
3T
LDA
ROL
F/IO;
c
."'
00
116
STA
ROL, X
MOVE RO TO RX
F/12:
/^ C
01
117
LDA
ROH
F714;
-5
01
1 13
STA
ROH, X
F/16:
60
119
RTS
1- 717:
<-* J
00
120
STAT
LDA
ROL
F 7 1 •? ;
31
00
121
3TAT2
STA
(ROL, X)
STORE BYTE INDIRECT
1- /IB;
AO
00
122
LDY
t /ID:
3:4
ID
1 23
3TAT3
STY
R 1 4H
INDIpATE RO IS RESULT REG
1- 71F:
F6
00
124
INK
INC
ROL, X
F721:
DO
02
125
ENE
I NK2
I NCR RX
F7:'.3:
F6
01
126
I HZ
ROH. X
F725:
60
127
irjl<2
RTS
h 726:
Al
00
123
LDAT
LDA
(ROL, X )
LOAD INDIRECT (RX)
F/28:
•Z--J
00
129
STA
ROL
TO RO
F/2A
AO
00
i:30
LDY
#S0
F/2C:
34
01
131
STY
ROH
ZERO HIGH-ORDER RO BY 1 E
F71'l-:
FO
ED
132
EEQ
STATS
ALWAYS TAKEN
F/30-
AO
00
1 :33
POP
LDY
#$0
HIGH ORDER BYTE =
FO
06
134
BEQ
PQP2
ALWAYS TAKEN
F/:34:
20
66
F7
1 :35
PCiPD
JGR
DCR
DECR RX
F/;37:
Al
00
1:56
LDA
(ROL, X )
POP HIGH-ORDER BY ft SHX
F7;39:
A3
137
TAY
SAVE IN Y-REG
["/:3A:
20
66
F7
1 33
Pi;iP2
.JSR
DCR
DECR RX
f-73D:
Al
00
1 39
LDA
(ROL, X)
LOW -ORDER BYTE
F73F:
o._'
00
140
STA
ROL
TO RO
F/41 :
34
01
141
STY
ROH
F/43:
AO
00
142
P0P3
LDY
#«0
INDICATE RO AS LAST
F745:
34
ID
143
STY
R14H
RESULT REG
F747:
60
144
RTS
f";4S:
20
26
F7
145
LDDAT
JSR
LDAT
LOW BYTE TO RO, I NCR RX
r/4B:
Al
00
146
LDA
(ROL, X)
HIGH-ORDER BYTE TO RO
r /4D:
35
01
147
STA
ROH
F74F:
4C
IF
F7
143
jrip
INR
I NCR RX
F/52-
20
17
F/
149
ST DAT
JSR
STAT
STORE INDIRECT LOW-ORDCR
F7t";5:
C
MO
01
150
LDA
ROH
BY IE ANU I NCR RX. THEN
F/57:
31
00
151
STA
(ROL, X )
STORE HIGH-ORDER BYTE.
F75'"':
4C
IF
F7
152
Jni-'
INR
I NCR RX ANLI RErLri:N
F7^C.
20
66
F/
153
3TPAT
JSR
DCR
DECR RX
F/5J- :
A5
00
154
LDA
ROL
F761 :
31
00
155
STA
(ROL, X )
STORE RO LOW BYTE @RX
F/63:
4i:
43
F7
1 56
JMP
POPS
INDICATE RO AS LAST RSLT RE
1 766
E:5
00
157
DCR
LDA
ROL, X
F 763:
DO
(.''2
153
ENE
DCR2
DECR RX
F76A:
06
01
159
DEC
ROH, X
h /6C
D6
00
160
DCR2
DEC
ROL, X
r76E
60
161
RTS
'^76F:
AO
00
162
SUB
LDY
#40
RESULT Tn ,w
Distributed under the Creative Commons License on page 5
Page 0132 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
1 45
P. M
10/3^
197/
PAGE
4
F//1
1 63
SEC
NOTE Y-REG = 13*2
FOR CPR
F V "/ 2
AS
00
164
LDA
ROL
F/74
Fb
00
165
3BC
ROL, X
F/'74
00
00
166
3TA
ROL< Y
RO-RX TO RY
i /79
1-1 -t
01
167
LDA
RCH
F/VE
F5
01
163
;?BC
ROH. X
F/7D
99
01
00
1 69
SUL-(2
'STA
ROH. Y
F/80
93
170
TYA
LAST RESULT REG*2
F731
69
00
171
ADC
#*0
CARRY TO LSB
F783
3^.
1 D
172
ST A
R14H
f;s5
60
173
RTS
F/S6
AS
00
174
ADD
LDA
ROL
F ;so
75
00
175
ADC
ROLi X
F73A
00
176
STA
ROL
ROi-RX TO RO
h 7;3C
AS
01
177
,LDA
ROH
i
F7::;E
75
01
173
ADC
ROH. X
F7V0
AO
00
179
LDY
#$0
RO FOR RESULT
F 792
FO
C9
130
EEQ
SUb2
FINISH ADD
F794
A5
IE
131
BS
LDA
R15L
NOTE X-REO IS 12^2
r796
20
19
F/
1 32
.J3R
STAT2
PUSH LOU! PC BY IE VIA R12
F 799
A5
IF
133
LDA
R15H
F/9B
20
19
F7
134
JSR
STAT2
PUSH HIGH-ORDEK PC
BY re
K 79E
IfJ
1 35
BR
CLC
F79F
BO
OE
136
BNC
ECS
BNC 2
NO CARRY TEST
F7A1
Bl
IE
137
BRl
LDA
( R 1 5L) , Y
DISPLACEMENT BY 1 E
K 7 A3
10
01
133
EPL
BR2
F7At.
33
139
DEY
K/A6
65
IE
190
BR2
ADC
R 1 5L
ADO TO PC
F7A;5
IE
191
STA
R15L
F7AA
9S
192
TYA
F7AB
65
IF
193
ADC
R15H
F7AD
IF
194
STA
R15H
I-7AF
60
195
BNC2
RTS
F7B0
BO
EC
196
BC
BCS
BR
FyB2
60
197
RTS
F7B3
OA
1 93
BP
A3L
A
DOUBLE RESULT-REG
INDEX
F 7t;4
AA
199
TAX
TO X-REG FOR INuEXING
[-7B5
B5
01
200
LDA
ROH, X
TEST FOR PLUS
F/b7
10
ts
201
EPL
ERl
BRANCH IF SO
h"/B9
60
202
RTS
F7BA
OA
203
BM
ASL
A
DOUbiLE RESULT-REG
INUEX
h 7BB
AA
204
TAX
F7BC
B5
01
205
LDA
ROH, X
TEST FOR MINUS
h / EE
30
El
206
EMI
ERl
F 7C0
60
207
RTS
F7C1
OA
203
BZ
ASL
A
DOUBLE RESULT-REG
INUEX
r /C2
AA
209
TAX
F 7C3
B5
00
210
LDA
ROL, X
TEST FOR ZERO
h 7C5
1^.
01
21 1
OR A
ROH, X
(BOTH BYTES)
F7C7
FO
DS
212
EEQ
ERl
BRANCH IF SO
F/C9
60
2 1 3
RTS
H 7CA
OA
214
ENZ
ASL
A
DOUBLE RESULT-REG
INUEX
F7CB
AA
215
TAX
F/CC
B5
00
216
LDA
ROL. X
TEST FOR NOrJZERO
Distributed under the Creative Commons License on page 5
Page 0133 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
1 ; 45
P. M,
10/:-
/ 1977
PAGE;
5
f-VCE
15.
01
217
or;'A
ROH, X
(BOTH BYTES)
F /UO
DO
CF
213
ERl
BRANCH IF SO
F / 02
60
219
RTS
F/U3
OA
220
Era
ASL
A
DOLIbiLE RESULT-REG
INiiEX
F/D4
AA
221
TAX
F7Li5
B.'S
00
222
LDA
ROL, X
CHECK BOTH BY 1 E3
r /U7
35
■01
'ArJD
ROH, X
FOR SFF (MINUS 1)
F ;d9
49
FF
224
Eor<
*fSFF
F /DB
FO
C4
225
BEQ
BRl
BRANCH IF 30
F /DD
60
226
RTS
F/LiC
OA
227
Efjn 1
ASL
A
DCUb'LE' RESULT-REG
INDEX
F/DF
AA
223
TAX
i- /to
Eb
00
229
LDA
ROL. X
F/E2
35
01
230
ANU
ROH, X
CHK BOTH EYThS FOR
NO SFF
F/!£4
49
FF
t
23 1
^EOR
ifSFF
F/t6
DO
t:9
232
EtJE
BRl
BRA.N'CH IF rJOT HINU
S I
F /hS
60
233
rJUL
RTS
F /t9
A 2
1:3
234
R-5
LDX
»$i;3
12»2 FOR R12 A3 STK PNTR
F7hB
20
66
F7
235
J3R
Di::R
DECR STACK POINTER
K7tE
Al
00
236
LDA
(ROL, X)
POP HIGH RE 1 URN ADR TO PC
F/FO
:55
IF
237
STA
R15H
F7F2
20
66
r/
233
JSR
DOR
SAME FOf^ LOW-ORDER
BYTE
F7F5
Al
00
239
LDA
(ROL, X)
F 7F7
S5
IE
240
STA
R15L
F/F9-
60
241
RTS
F/FA-
4C
C7
F6
242
RTN
JMP
RTNZ
CCE:5b:
FUL AS
3EMBLY:
NO ERRORS
Distributed under the Creative Commons License on page 5
Page 0134 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
£r Llvf'.'iJ E : .:
kFt r 1
£hr FE
ADD
K/S6
0094
BC
f- 7 BO
0083
B!^
F706
0097
B«
1- 7BA
0007
BMl
K/DS
0093
BrJC
P/9F
0001
&NC2
f;af
1 36
t;r4M 1
K7BE
0095
bUZ
K/CA
0091
BP
h 7B3
0005
BR
F79E
0079
1 96
BR 3
I-7A1
0201
0206
0212
BR2
F7A6
1 33
B'.'TBL
F6E4
005b
B3
F794
0101
BZ
F771
00:59
cni
1 00
DCR
F766
1 04
01 35
1 33
DCIv'2
F76C
1 50
irJR
F71F
0102
1 43
1 52
1NK2
F725
1 25
LU
F705
0073
1 )jAT
F726
0002
1 45
LOUAT
F7^3
0(:;36
Nil!.
r- 7 E £1
0103
105
0106
Of-'TBL
rAE:3
0049
F730
0090
r7:3A
0134
pijr'3
F743
1 56
PuPD
F/34
0093
RO! 1
000 1(2)
0065
0112
1 1 3
0167
1 63
0169
HOL
0000 ( Z )
0063
1 09
0111
1 39
1 40
1 46
0174
1 75
1 76
00 1 D ( Z )
0044
005 7
1 23
00 1 F ( Z )
0023
0033
0054
R15L
00 IE
0026
0031
0037
0137
1 90
1 9 1
r;f:sTORE
FF.3F
0062
[ 7E9
0099
R"l ti
I-7FA
007/
RTrJZ
F/oi:.7
0242
SI6PAC1
00F7
0034
■E:AVt£
l"F4A
00 24
:r.CT
F7u3
0076
SLT2
K6E2
0073
Z
1 6CF
1 OS
ST
F70£
003.0
SI AT
F 717
r;C34
0149
STATz
F719
1 32
1 34
SlYlf::-;
f-71D
0132
S I BAT
F752
0003
in PAT
F75C
0092
SUB
I-76F
0096
SiJL-;2
F77D
0130
S'^ 1 A
1- 639
F6V2
00- Z'O
S'.J16C
Ft 93
0C29
Ft-E
00 32
022^
02:--! 2
0235 0233
0117
0177
0115
0151
0210
0143
0074
0042
0240
0113
017S
01 16
0154
0216
0172
1 S3
0052
1 26
0200
1 20
1 55
0222
C 1 93:
0063
0131
0205
0121
015/
0229
0141
0211
0124
0160
0236
0194 0237
0064 0067
0147 0150 0159
0217 0223 0230
0123 0129 0136
0164 0165 0166
0239
0071 0072 01 SI
I Page
Distributed under the Creative Commons License on page 5
0135 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
rOBR F6B9 0043
10 BR 2 FA.BF 0053
Distributed under the Creative Commons License on page 5
Page 0136 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Apple-II
6502 Code Relocation Program
14 November 1977
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0137 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0138 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
A 6 5 2
CODE RELOCATION
PROGRAM
for the
APPLE-II COMPUTER
S. Wozniak (WOZ)
November 14 , 1977
Distributed under the Creative Commons License on page 5
Page 0139 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 1
APPLE-II MACHINE CODE RELOCATION PROGRAM
Quite frequently I have encountered situations calling for
relocation of machine language (not BASIC) programs on my 6502-
based APPLE-II computer. Relocation means that the new version must
run properly from different memory locations than the original.
Because of the relative branch instruction, certain small 6502
programs need simply be moved and not altered. Others require only
minor hand modification, which is simplified on the APPLE-II by the
built-in disassembler which pinpoints absolute memory reference
instructions such as JMPs and JSRs . However, most of the situations
which I have encountered involved rather lengthy programs containing
multiple data segments interspersed with code. For example, I once
spent over an hour to hand-relocate the 8K byte APPLE8II monitor and
BASIC to run from RAM addresses and at least one error probably
went by undetected. That relocation can now be accomplished in a
couple minutes using the relocation program described herein.
Distributed under the Creative Commons License on page 5
Page 0140 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 2
The following, situations call for program relocation:
(1)
Two programs which were written to run in identical
T^pcido and run in memory concurrently,
locations must now resiae aim ^ i^ii
(2)
A prograrf, currently runs from ROM. In order to modify
its operation experimentally, a version must be genera-
ted which runs from RAM (different addresses).
(3)
A program currently running in RAM must be converted to
run from EPROM or ROM addresses.
(4)
A program currently running on a 16K machine must be
relocated in order to run on a 4K machine. Furthermore,
the relocation may have to be performed on the smaller
machine .
(5)
Due to memory mapping differences, a program running on
an APPLE-I (or other 6502 based) computer falls into
unusable address space. on an APPLE-II (or other) computer.
(6)
Due to operating system variable assignment differences
either the page-zero or non-page-zero variable allocation
for a specific program may have to be modified when moving
the program from one make of computer to another.
(7)
A program exists as several chunks strewn about memory
v.nich must be combined in a single, contiguous block.
Distributed under the Creative Commons License on page 5 | Page 0141 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 3
(8) A program has outgrown the available memory space and
must be relocated to a larger 'free' space.
(9) A program insertion or deletion requires a chunk of the
program to move a few bytes up or down.
(10) On a whim, the user wishes to move a program.
Distributed under the Creative Commons License on page 5
Page 0142 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 4
PROGRAM MODEL
It is easy to visualize relocation as taking a program which
resides and runs in a 'source block' of memory and creating a
modified version in a 'destination block' which runs properly.
This model dictates that the relocation must be performed in an
environment in which the program may in fact r^eside in both blocks.
In many cases, the relocation is being performed because this is
impossible. For example, a program written to begin at location
$400 on an APPLE-I ($ stands for hex) falls in the APPLE-II screen
memory range. It must be loaded elsewhere on the APPLE-II prior
to relocation .
A more versatile program model is as follows. A program or
section of a program runs in a memory range termed the 'source block'
and resides in a range termed the 'source segments'. Thus a program
written to run at location $400 may reside at location $800. The
program is to be relocated so that it will run in a range termed
the 'destination block' although it will reside in a range termed
'destination segments' (not necessarily the same). Thus a program
may be relocated such that it will run from location $D000 (a ROM
address) yet reside beginning at location $C00 prior to being saved
on tape or used to burn EPROMs (obviously, the relocated program
cannot immediately reside at locations reserved for ROM). In some
cases the source and destination segments may overlap.
Distributed under the Creative Commons License on page 5
Page 0143 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 5
BLOCKS AND SEGMENTS EXAMPLE
Location during
Rel ocat ion
$800
$B87
$C00
SF87
Program runs from
location $400 .
on APPLE- I
4
Relocated version
runs from
location $D000
on APPLE-II
Relocation
SOURCE BLOCK; $400-$787 DEST BLOCK: $D000-$D387
SOURCE SEGMENTS: $800-SB87 DEST SEGMENTS: $C00-$F87
Distributed under the Creative Commons License on page 5
Page 0144 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 6
THE RELOCATION ALGORITHM
(1) Set SOURCE PTR to beginning of source segment and BEST PTR
to beginning of destination segment.
(2) Copy 3 bytes from source segment (using SOURCE PTR) to temp
INST area.
(3) Determine instruciton length from opcode (1, 2, or 3 byte),
(4) If two byte instruction with non-zero-page addressing mode
(immediate or relative) then go to (7).
(5) If two byte instruction then clear 3rd byte so address field
is 0-255 (zero page).
(6) If address field (2nd and 3rd bytes of INST area) falls within
source block , then substitute
ADR - SOURCE BLOCK BEGIN + DEST BLOCK BEGIN
(7) Move 'length' bytes from INST area to dest segment (using
DEST PTR). Update SOURCE and DEST PTRs by length.
(8) If SOURCE PTR is less than or equal to SOURCE SEGMENT END
then goto (2), else done.
Distributed under the Creative Commons License on page 5
Page 0145 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 7
DATA SEGMENTS
The problem with relocating a large program all at once is that
data (tables, text, etc.) may be interspersed throughout the code.
Thus data may be 'relocated' as though it were code or might cause
some code not to be relocated due to boundary uncertainty introduced
when the data takes on the multi-byte attribute of code. This problem
is circumvented by considering the 'source segments' and 'destination
segments' sections to contain both code and data segments.
CODE AND DATA SEGMENTS EXAMPLE
$800 —
Code Segment
$800-$892
Data Segment
$893-$992
Code Segment
$993-$ABF
Data Segment
$ACO-$ACF
Code Segment
$B87
$ACF-$B87
The source code segments are relocated to the 'destination segments'
area and the source dat a segments are moved . Note that several commands
will be necessary to accomplish the complete relocation.
Distributed under the Creative Commons License on page 5
Page 0146 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 8
USAGE
1. Load RELOC by hand or off tape into memory locations $3A6-$3FA.
Note that locations $3FB-$3FF are not disturbed by tape load
versions to insure that the APPLE-II interrupt vectors are not
clobbered. The monitor user function (Control-Y) will now
call RELOC as a subroutine at location $3F8.
2. Load the source program into the 'source segments' area of memory
if it is not already there. Note that this need not be where
the program normally runs.
3. Specify the source and destination block parameters, remembering
that the blocks are the locations that the program normally
runs from, not the locations occupied by the source and destinati
segments during the relocation. If only a portion of a program
is to be relocated then that portion alone is specified as the
block .
♦ BEST BLOCK BEG < SOURCE BLOCK BEG . END *
Note that the syntax of this command closely resembles that of
the MONITOR 'MOVE' command. The initial '♦' is generated by
the MONITOR, not typed by the user.
Distributed under the Creative Commons License on page 5
Page 0147 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 9
Move an data segments and relocate all code segments in sequential
(increasing address) order.
First SeRment (if CODE)
* DEST SEGMENT BEG < SOURCE SEGMENT BEG . END Y*^
First Segment (if DATA)
* DEST SEGMENT BEG < SOURCE SEGMENT BEG . END M
Subsequent segments (if CODE)
* . SOURCE SEGMENT END (Relocation)
S ubsequent segments (if DATA)
* . SOURCE SEGMENT END M (Move)
Note that it is wise to prepare a list of segments (code and data)
prior to relocation.
If the relocation is performed 'in place' (SOURCE and DEST
SEGMENTS reside in identical locations) then the SOURCE SEGMENT
BEG parameter may be ommitted from the first segment relocate
( or move ) .
Distributed under the Creative Commons License on page 5
Page 0148 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 10
EXAMPLES
1. Straightforward Relocation
Program A resides and runs in locations $800-$97F. The relo-
cated version will reside and run in locations $A00-$B7F.
SOURCE SEGMENTS
$800-^
$97F-
CODE
$800-$88F
DATA
$890-$8AF
CODE
$8B0-$90F
DATA
$910-$93F
CODE
$940-$97F
SOjRCE block $800-$97F
SOURCE SEGMENTS $S00-$97F
DEST SEGMENTS
$A00-
$B7F
CODE
$A00-$A8F
DATA
$A90-$AAF
CODE
$ABO-$BOF
DATA
$B10-$B3F
CODE
$B40-$B7F
DEST BLOCK $A00-$B7F
DEST SEGMENTS $A00-$B7F
(a) Load RELOC
(b) Define blocks
* AOO < 800 . 97F *
(c) Relocate first segment (code).
* AOO < 800 . 88F Y*"^
Distributed under the Creative Commons License on page 5 I Page 01 49 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 11
(d) Move and relocate subsequent segments in order.
* . 8AF M (data)
* . 90F (code)
* . 93F M (data)
+ . 97F (code)
Note that step (d) illustrates abbreviated versions of
the following commands:
+
A90
<
890
8AF
M
(data)
*
ABO
<
8B0
90F
yC
( code )
*
BIO
<
910
93F
M
(data)
*
B40
<
940
97F
yC
( code )
Distributed under the Creative Commons License on page 5
Page 0150 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 12
Index into block
Assume that the program of example 1 uses an indexed reference
into the data segment at $890 as follows:
LDA 7B0,X
The X-REG is presumed to contain $EO-$FF. Because $7B0 is
outside the source block, it will not be relocated. This may
be handled in one of two ways.
(a) The exception is fixed by hand, or
(b) The block specifications begin one page lower than the
addresses at which the original and relocated programs
begin to account for all such 'early regerences'. In
step (b) of example (1) change to:
+ 900 < 700 . 97F *
Note that program references to the 'prior page' (in this
case the $7XX page) which are not intended to be relocated
will be.
Distributed under the Creative Commons License on page 5
Page 0151 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 13
3. Immediate Address References
Assume that the program of example (1) has an iminediate ref-
erence which is an address. For example,
LDA #$3F
STA LOCO
LDA #$08
STA LOCI
JMP ( LOCO )
In this example, the LDA #$08 will not be changed during relocation
and the user will have to hand-modify it to $0A.
4. User function (Y^) programs
Relocating programs such as RELOC introduces another irregularity.
C
Because RELOC uses the MONITOR user function command (Y )
its entry point must remain fixed at $3F8 . The rest of RELOC
may be relocated anywhere in memory (which is trivial since
RELOC contains no absolute memory references other than the
JMP at $3F8). The user must leave the JMP at $3F8 undisturbed
or find some way other than to pass parameters.
Distributed under the Creative Commons License on page 5
Page 0152 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 14
5. Unusable block ranges
A program was written to run from locations $400-$78F on an
APPLE-I. A version which will run in ROM locations $D000-$D38F
must be generated. The source (and destination) segments may
reside in locations $S00-$B8F on the APPLE-I I where relocation
is performed.
Locat ions
dur i ng
r e 1 ocat ion
$800
$B8F
SEGMENTS, SOURCE AND DEST
CODE
$800-$97F
DATA
$980-$9FF
CODE
$A00-$B8F
Runs from locations
$400-$78F on APPLE-I
but must be relocated
to run from locations
$D000-$D38F on the
APPLE-I I .
SOURCE BLOCK $400-$78F
SOURCE SEGMENTS $800-$B8F
DEST BLOCK $D000-$D38F
DEST SEGMENTS $800-$B8F
(a) Load RELOC
(b) Load original program into locations $800-$B8F (despite the
fact that it doesn't run there).
(c) Specify block parameters (i.e. where the original and
relocated \ersions will run)
* DOOO < 400 . 78F y"^ *
I Page
Distributed under the Creative Commons License on page 5
0153 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 15
(d) Move and relocate all segments in order.
* 800 < 800 . 97F Y*"^ (first segment, code)
* . 9FF M (data)
* . BBF yC (code)
Note that because the relocation is done 'in place' the
SOURCE SEGMENT BEG parameter is the same as the DEST SEGMENT
BEG parameter ($800) and need not be specified. The initial
segment relocation command may be abbreviated as follows:
* 800 < . 97F Y*^
6. The program of example (1) need not be relocated but the page
zero variable allocation is from $30 to $3F. Because these
locations are reserved for the APPLE-II system monitor, the
allocation must be changed to locations $80-$8F. The source
and destination blocks are thus not the program but rather
the variable area.
SOURCE BLOCK $20-$2F DEST BLOCK $80-$8F
SOURCE SEGMENTS $800-$97F DEST SEGMENTS $800-$97F
(a) Load RELOC
(b) Define blocks
+ 80 < 20.2F Y*-^ *
(c) Relocate code segments and move data segments in place.
*
800 <
88F y'^
( code )
. 8AF
M
( dat a )
. 90F
yC
( code )
. 93F
M
(data)
*
. 97F
yC
( code )
Distributed under the Creative Commons License on page 5
Page 0154 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 16
7. Split blocks with crrj.ss-ref erenci ng
Program A resides and runs in locations $800-$8A6. - Program B
resides and runs in locations $900-$9Fl. A single, contiguous
program is to be generated by moving program B so that it
immediately follows program A. Each of the programs contains
memory references within the other. It is assumed that the
programs contain no data segments.
SOURCE SEGMENTS
BEST SEGMENTS
$800 —
$8A6 -
$900 —
$9F1 —
Program A
$800-$8A6
Unused
Program B
$900-$9Fl
$800
$8A6
$8A7-
Program A
$aOO-$8A6
Program B
SOURCE BLOCK $900-$9Fl DEST BLOCK $8A7-$998
SOURCE SEGMENTS $800-$8A6 (A) DEST SEGMENTS $800-$8A6 (A)
$900-$9Fl (B) $8A7-$998 (B)
(a) Load RELOC
(b) Define blocks (program B only)
* 8A7 < 900 , 9F1 Y'
Distributed under the Creative Commons License on page 5
Page 0155 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 17
(c) Relocate each of the two programs ' individually . Program
must be relocated even though it does not move.
* 800 <. 8A6 Y*^ (program A, 'in place')
* 8A6 < 900 . 9F1 y'^ (program B, not 'in place')
Note that any data segments within the two
necessitate additional relocation and move
programs would
commands .
Code deletion.
4 bytes of code are to be removed from within a program and the
program is to contract accordingly.
SOURCE SEGMENTS DEST SEGMENTS
$800-
Remove 4
bytes here
$97F-
CODE
$800-$88F
DATA
S890-$8AF
CODE
$8B0-$90F
)
DATA
$910-$93F
CODE
$940-$97F
$800-
$97B-
CODE
$800-$88F
DATA
$890-$8AF
CODE
$8B0-$90B
DATA
$90C-$93B
CODE
$93C-$97B
SOURCE BLOCK
$8C4-$97F
DEST
BLOCK $8C0-$97B
SOURCE SEGMENTS
$800-$88F
( code )
DEST
SEGMENTS $800-$88F
(code )
$890-$8AF
(data)
$890-$8AF
(data)
$8B0-$SBF
( code )
$8B0-$8BF
(code )
$8C4-$90F
( code )
$8C0-$90B
(code )
$910-$93F
( dat a )
$90C-$93B
(data )
( r-nrie ~1
$93C-$97B
(code )
I Page
Distributed under the Creative Commons License on page 5
0156 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 18
(a) Load HELOC
(b) Define blocks
* SCO < 8C4 . 97F *
(c) Relocate code segments and move data segments In ascending
address sequence.
* 800 <. 88F (code, 'in place')
* . 8AF M (data)
* . 8BF yC (code)
+ SCO < 8C4 . 90F Y^ (code, not 'in place')
* . 93F M (data)
* . 97F Y^ (code)
(d) Relative branches crossing the deletion boundary will be
incorrect since the relocation process does not modify them
(only zero-page and absolute memory references). The user
must patch these by hand.
Distributed under the Creative Commons License on page 5
Page 0157 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 19
9. Relocating the APPLE-II monitor ( $F800-$FFFF ) to run in RAM
(■S800-$FFF)
SOURCE BLOCK $F700-$FFFF
(see example (2) )
DEST BLOCK $700-$FFF
SOURCE SEGMENTS $F800-$F961 (code) DEST SEGMENTS $800-$961 (code)
$F962-$FA42 (data) $962-$A42 (data)
$FA43-$FB18 (code) $A43-B18 (code)
$FB19-$FB1D (data)
$FB1E-$FFCB (code)
$FFCC-$FFFF (data)
IMMEDIATE ADDRESS REFS (see example (3) )
$FFBF
$FEA8
(more if not relocating to page boundary)
$B19-$B1D (data)
$B1E-$FCB (code)
$FCC-$FFF (data)
(a) Load RELOC
(b) Block parameters
♦ 700 < F700 . FFFF Y *
(c) Segments
* 800 < F800
FA42 M
FB18
FBID M
FFCB Y^
FFFF M
F961 Y*-^ (first segment, code)
(data)
( code )
(data)
( code )
(data)
Distributed under the Creative Commons License on page 5
Page 0158 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 20
(c) Immediate address references
* FBF : E (was $FE )
* EA8 ; E (was $FE)
Distributed under the Creative Commons License on page 5
Page 0159 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 21
OTHER 6 502 SYSTEMS
The following details illustrate features specific to the APPLE-II
which are used by RELOC . If adapted to other systems, the convenient
and flexible parameter passing capability of the APPLE-II monitor
may be sacrificed.
1. The APPLE-II monitor command
* A^ < Ai . A2 Y*^ (Ai, A2, and A4 are addresses)
vectors to location $3F8 with the value A^ in locations $3C (lo
and $3D (high), Ag in locations $3E (low) and $3F (high),
and A4 in locations $42 (low) and $43 (high). Location
$34 (YSAV) holds an index to the next character of the command
buffer (after the Y^). The command buffer (IN) begins
at $200.
2. If Y^ is followed by an then the block parameters are
simply preserved as follows:
Parameter
DEST BLOCK BEG
SOURCE BLOCK BEG
SOURCE BLOCK END
Preserved at
$8, $9
$2, $3
$4 , $5
SWEET16 Reg Name
TOBEG
, FRMBEG
FRMEND
If Y^ is not followed by and '*' then a segment relocation is
initiated at REL0C2 ($3BB). Throughout, Al ($3C, $3D) is the
source segment pointer and A4 ($42, $43) is the destination
segment pointer.
Distributed under the Creative Commons License on page 5
Page 0160 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 22
4. INSDS2 is an APPLE-II monitor subroutine which determines the
length of a 6502 instruction in the variable LENGTH (location $2F)
given the opcode in the A-REG.
Instruction type LENGTH
Invalid
1 byte ,
2 byte 1
3 byte 2
5. The code from XLATE to SW16RT ($3D9-$3E6) uses the APPLE-II
16-bit interpretive machine, SWEET16. The target address of
the 6502 instruction being relocated (locations $C low and
$D high) occupies the SWEET16 register named ADR. If ADR is
between FRMBEG and FRMEND (inclusive) then it is replaced by
ADR - FRjMBEG + TOBEG.
6. NXTA4 is and APPLE-II monitor subroutine which increments Al
(source segment index) and A4 (destination segment index).
If Al exceeds A2 (source segment end) then the carry is set,
otherwise it is cleared.
Distributed under the Creative Commons License on page 5
Page 0161 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
6502 RELOCATION SUBROUTINE
4:36 P.M., 11/10/1977 PAGE: 1
1
TITLE '6502 RELOCATION
SUBROUT INE
2
************************
* "k
3
*
■k
4
ddU/ RELOCATION
A
5
Subroutine
"k
6
it
7
' *
i. DEFINE BLOCKS
it
8
If
*A4 <A1 . A2 'Y
it
9
ie
('Y IS CRTL-Y)
ic
10
it
11
*
2. FIRST SEG
*
12
*A4<A1.A2 Y
it
1 3
( i r UUUt. )
14
*
it
15
*
*A4<A1.A2 M
16
!*
(IF MOVE)
-*
1 7
*
*
18
*
3. SUBSEQUENT SEGS
*
19
*
* .A2 "Y OR *.A2 M
*
20
♦
it
21
*
WOZ 11-10-77
*
22
*
APPLE COMPUTER INC.
23
*
*
24
**************************
25
PAGE
Distributed under the Creative Commons License on page 5
Page 0162 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
RELOCATION SUBR EQUATES
26
SUBTTL
RELOCATION SUBR
EQuATEb
27
RIL
EP2
$2
28
INST
EPZ
$B
j-bxlt J-Nbi rinLiU.
29
LENGTH
EPZ
$2F
30
YSAV
EPZ
$34
CMND BUF POINTbR.
31
AIL
EPZ
$3C
APPLE-II MON PARAM AREA.
32
A4L
EPZ
§42
APPLE — 1 1 MON rAKAM Ktkj ^4
33
IN
EQU
$200
HON CMND BUF.
34
SW16
EQU
$F689
SWEET16 ENTRY.
35
INSDS2
EQU
$F88E
DISASSEMBLER ENTRY.
36
NXTA4
EQU
§FCB4
POINTER INCR SUBR.
37
FRMBEG
EPZ
$1
SOURCE BLOCK BEGIN.
38
FRMEND
EPZ
$2
SOURCE BLOCK END.
39
TOBEG
EPZ
$4
DEST BLOCK BEGIN.
40
ADR
EPZ
$6
ADR PART OF INST.
41
PAGE
Distributed under the Creative Commons License on page 5
Page 0163 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
4:36 P.M. , 11/10/1977
42
43
03A6
A4
34
44
03A8
B9
00
02
45
03AB
. C9
AA
46
03AD
DO
OC
47
03AF
E6
34
48
03B1
A2
07
49
03B3
B5
3C
50
03B5
95
02
51
03B7
CA
52
0388
10
F9
53
03BA
60
54
033B
AO
02
55
03BD
Bl
3C
56
03BF
99
OB
00
57
3C2
88
58
03C3
10
F8
59
03C5
20
8E
F8
60
03C8
A6
2F
61
03CA
CA
62
03CB
DO
OC
63
03CD
A5
OB
64
03CF
29
OD
65
03D1
FO
14
66
03D3
29
08
67
03D5
DO
10
68
03D7
85
OD
69
03D9
20
89
F6
70
3DC
22
71
03DD
: D6
72
3DE
02
06
73
03E0
25
74
03E1
: Bl
75
03E2
02
02
76
03E4
A4
77
03E5
■ 36
78
03E6
00
79
03E7
A2
00
80
03E9
B5
OB
81
03EB
91
42
82
03ED
: E8
83
3EE
: 20
B4
FC
84
03F1
: C6
2F
85
03F3
: 10
F4
86
03F5
: 90
C4
87
3F7
: 60
88
89
03F8
: 4C
A6
03
90
****** * * SUCCESSFUL
6502 RELOCATION SUBROUTINE
SUBTTL 6502 RELOCATION SUBROUTINE
RELOC
PAGE;
INIT
REL0C2
GETINS
XLATE
SW16RT
STINST
STINS2
USRLOC
ORG
$3A6
LDY
YSAV
CMND BUF POINTER.
LDA
IN, Y
NEXT CMND CHAR.
CMP
j(5AA
'*'?
8NE
RELOC 2
NO, RELOC CODE SEG.
INC
YSAV
ADVANCE POINTER.
LDX
#$7
LDA
A1L,X
MOVE BLOCK PARAMS
STA
RIL, X
FROM APPLE-II MON
DEX
AREA TO SW16 AREA.
BPL
INIT
R1=S0URCE BEG, R2«
RTS
SOURCE END, R4=DEST BE(
LDY
#$2
LDA
(AIL) ,Y
COPY 3 BYTES TO
STA
INST, Y
SW16 AREA.
DEY
BPL
GETINS
JSR
INSDS2
CALCULATE LENGTH OF
LDX
LENGTH
INST FROM OPCODE.
DEX
0=1 BYTE, 1=2 BYTE,
BNE
XLATE
2=3 BYTE.
LDA
INST
AND
#$D
WEED OUT NON-ZERO-PAGE
BEQ
STINST
2 BYTE INSTS (IMM) .
AND
#$8
IF ZERO PAGE ADR
BNE
STINST
THEN CLEAR HIGH BYTE.
STA
INST+2
JSR
SW16
IF ADR OF ZERO PAGE
LD
FRMEND
OR ABS IS IN SOURCE
CPR
ADR
(FRM) BLOCK THEN
BNC
SW16RT
SUBSTITUTE ADR-
LD
ADR
SOURCE BEG+DEST BEG.
SUB
FRMBEG
BNC
SW16RT
ADD
TOBEG
ST
ADR
RTN
LDX
#$0
LDA
INST,X
STA
(A4L) ,Y
COPY LENGTH BYTES
INX
OF INST FROM
JSR
NXTA4
SW16 AREA TO
DEC
LENGTH
DEST SEGMENT. UPDATE
BPL
STINS2
SOURCE, DEST SEGMENT
BCC
REL0C2
POINTERS. LOOP IF NOT
RTS
BEYOND SOURCE SEG END.
ORG
S3F8
JMP
RELOC
ENTRY FROM MONITOR.
NO ERRORS
Distributed under the Creative Commons License on page 5
Page 0164 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
CROSS-
REFERNCE:
6 50 2 RELOCATION
AIL
003C
0050
0056
A4L
0042
082
ADR
0006
0072
0074
0078
FRMBEG
0001
0075
FRMEND
0002
0071
GETINS
03BD
0059
IN
0200
0045
INIT
03B3
0053
INSDS2
F88E
0060
INST
OOOB
0057
0064
0069
LENGTH
002F
0061
0085
NXTA4
FCB4
0084
RIL
0002
0051
RELOC
03A6
0090
REL0C2
03BB
0047
0087
STINS2
03E9
0086
STINST
03E7
0066
0068
SW16
F689
0070
SW16RT
03E6
0073
0076
TOBEG
0004
0077
USRLOC
03F8
XLATE
03D9
0063
YSAV
0034
0044
0048
FILE:
Distributed under the Creative Commons License on page 5
Page 0165 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0166 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Apple-II
Renumbering and Appending
BASIC Programs
15 November 1977
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0167 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0168 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
RENUMBERING AND APPENDING
BASIC PROGRAMS
on the
APPLE-II COMPUTER
S. Wozniak (WOZ)
November 15, 1977
Distributed under the Creative Commons License on page 5
Page 0169 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 1
RENUMBERING AND APPENDING APPLE-II BASIC PROGRAMS
The answer to the question "what do 5, 11, 36, 150, 201, and 588
have in common?" is given as "adjacent rooms in the Warsaw Hilton";^
but might just as well be "adjacent line numbers in my last BASIC
program." The laws of entropy insure that the line numbers of a
debugged and operational BASIC program give the appearance of having
been selected by a KENO machine.* Many a time I have spent an extra
hour to retype a finished program while spacing the line numbers
evenly just to make it 'look good'.
Another difficulty which I have experienced is joining two
BASIC programs into a single, larger one. This 'append' operation
is easier to accomplish by hand than renumbering. The sophistocated
user can examine the BASIC memory map and perform some manual mani-
pulations to join the programs providing that the line numbers do
not overlap. Still, the manual append operation is highly prone
to error.
1
The
New
Official Pol i sh/ Italian Joke Book, L.
York, N.Y. , 1973, p. 17
Wilde, Pinnacle Books,
* In fact while several texts detail how the boundary conditions
of a KENO game lead to predictable outcomes, finished programs
seldom exhibit this property.
Distributed under the Creative Commons License on page 5
Page 0170 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 2
The APPLE-II BASIC user now has a solution to these needs in
the for,m of a hand- or tape-loadable program, RENUM/APPEND , described
herein. The CALL command is used to activate one of three machine
level programs. The renumber operation (RENUM) requires user speci-
fication of the original line number range over which renumbering
is to occur, the new initial line number to be applied to the range,
i
and the new line number increment to use. The example below specifies
that lines 200 to 340 be renumbered starting with 100 and spaced
by 10' s.
RANGE BEGIN 200
RANGE END 340
NEW BEGIN 100
NEW INCREMENT 10
A second RENUM entry renumbers the entire program, relieving
the user of the need to specify the range begin and end parameters.
The append operation (APPEND) reads the second user (BASIC) program
off tape with the first in memory.
Renumber and append error conditions (memory full and line number
overlap) are detected just as in BASIC. In case of error the user
is notified and no program alteration occurs.
Distributed under the Creative Commons License on page 5
Page 0171 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 3
USING RENUM/ APPEND
1. Load RENUM/APPEND (* 300. 3D4 R)
Note that the high-order bytes of page 3 are not loaded, preventing
inadvertant alteration of the interrupt and user function (YC)
vectors. The is generated by the MONITOR, not the user.
2. Load a BASIC program.
3. To renumber entire program:
POKE 2 , START L
POKE 3, START H
POKE 4, INCR L
POKE 5, INCR H
CALL 768
User must supply low and high bytes
of newSTARTing line number.
User must supply low and high bytes
of new line number INCRement .
(does not alter locations 2-5)
Note: START L is equivalent to START MOD 256
START H is equivalent to START / 256
4. To renumber a range of the program
POKE
2 ,
START L
POKE
3 ,
START H
POKE
4,
INCR L
POKE
5,
INCR H
POKE
6,
RANGE START
L
POKE
7,
RANGE START
H
POKE
8 ,
RANGE END L
POKE
9 ,
RANGE END H
CALL
776
User must supply low and high bytes
of renumber range starting line number.
User must supply low and high bytes
of renumbei' range ending line number.
(does not alter locations 2-9)
Distributed under the Creative Commons License on page 5
Page 0172 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 4
5. To append program #2 (larger line numbers) to program #1
(smaller line numbers):
(a) Load program #2
(b) CALL 956
Be sure you are running the -fape of program #1 as ^his
command will load it.
(c) If you get a memory full error then use the command
CALL 973 to recover the original program.
Distributed under the Creative Commons License on page 5
Page 0173 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 5
ERRORS
1. If not enough free memory exists to contain the line number
table during pass 1 of RENUM then the message '(beep) *** MEM FULL ERI
is displayed and no renumbering occurs. The same message is
displayed if not fenough free memory exists to hold the product
of an APPENti. In the case of APPfeND, the user will have to type
the BASIC command CALL 973 to recover his original program.
The user can free additional memory by eliminating all active
BASIC variables with the CLR command.
2. If renumbering results in a line number overlap (detected during
pass 1 of RENUM) then the message '(beep) *** RANGE ERR' is
displayed and no renumbering occurs. This error may mean that
one or more parameters were not specified or were incorrectly
specified .
CAUTIONS
1. When appending a program, always load the one with greater
line numbers first.
2. The user must be aware that branch target expressions may not
be renumbered. For example, the statement GO TO ALPHA will
not be modified by RENUM. The statement GO TO 100 + ALPHA
will be modified only to reflect the new line number assigned
to the old line 100.
Distributed under the Creative Commons License on page 5
Page 0174 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 6
APPLE- I I BASIC STRUCTURE
An understanding of the internal representation of a BASIC
program is necessary in order to develope RENUMBER and APPEND
algorithms. Figure 1 illustrates the significant pointers for a
program in memory. Variable and symbol table assignment begins at
the location whofee address is contained in the pointer LOMEM ($4A
and $4B where '$' stands for hex). This is $800 (2048) on the
APPLE-II unless changed by the user with the LOMEM; command.
A second pointer, PV (Variable Pointer, at $CC and $CD) contains
the address of the location immediately following the last location
allocated to variables. PV is equal to LOMEM if no variables are
actively assigned as is the case after a NEW, CLR, or LOMEM: command.
As variables are assigned, PV increases.
The BASIC program is stored beginning with the lowest numbered
line at the location whose address is contained in the pointer PP
(Program Pointer, at $CA and $CB) . The pointer HIMEM ($4C and $4D)
contains the address of the location immediately following the
last byte of the last line of the program. This is normally the top
of memory unless changed by the user with the HIMEM: command.
As the program grows, PP decreases. PP is equal to HIMEM if there
is no program in memory. Adequate checks in the BASIC insure that
PV never exceeds PP. This in essence says that variables and program
are not permitted to overlap.
Distributed under the Creative Commons License on page 5
Page 0175 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 7
Lines of a BASIC program are not stored as they were originally
entered (in ASCII) on the APPLE-II due to a pre-translation stage.
Internally each line begins with a length byte which may serve as
a link to the next line. The length byte is immediately followed
by a two-byte line number stored in binary, low-order byte first.
Line numbers range from to 32767. The line number is followed
by 'items' of various types, the final of which is an ' end-of-1 ine '
token ($01). Refer to figure 2.
Single bytes of value less than $80 (128) are 'tokens' generated
by the translator. Each token stands for a fixed unit of text as
required by the syntax of the language BASIC. Some stand for keywords
such as PRINT or THEN while others stand for punctuation or operators
such as ' , ' or ' + ' .
Integer constants are stored as three consecutive bytes. The
first contains $B0-$B9 (ASCII '0'-'9') signifying that the next
two contain a binary constant stored low-order byte first. The line
number itself is not preceeded by $B0-$B9. All constants are
in this form including line number references such as 500 in the
statement GO TO 500. Constants are always followed by a token.
Although one or both bytes of a constant may be positive (less
than $80) they are not tokens.
Distributed under the Creative Commons License on page 5
Page 0176 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 8
Variable names are stored as consecutive ASCII characters with
the high order bit set. The first character is between $C1 and $DA
(ASCII 'A'-'Z'), distinguishing names from constants. All names
are terminated by a token which is recognizable by a clear high-order
bit. The '$' in string names such as A? is treated as a token.
String constants are stored as a token of value $28 followed
by ASCII text (with high-order bits set) followed by a token of
value $29. REM statements begin with the REM token ($5D) followed
by ASCII text (with high-order bits set) followed by the ' end-of -1 ine '
token .
Distributed under the Creative Commons License on page 5
Page 0177 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 9
Figure 1 - MEMORY MAP
BASIC
VARIABLES
LOMEM (start of variables)
($4A,4B)
PV (Variable Pointer, end of variables)
($CC,CD) ^
BASIC
PROGRAM
pp (Program Pointer, start of program)
($CA ,CB)
first line
— last line
— HIMEM (end of program)
($4C,4D)
Figure 2 - LINE REPRESENTATION
low
highj
length line number
byte
items
$01
end-of-line '
token
I Page
Distributed under the Creative Commons License on page 5
0178 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 10
Figure 3 - ITEMS
Constant ;
low
high]
$B0-$B9
Name (ABC); [~ $C 1 | | $C2
value
positive
token
$C3
negative
ASCII
□
positive
token
String Constant ("123"):
$28 1
$B1
1 1 $B2
$B3 1
1 $29
quote
token
negat ive
ASCII
quote
token
REM:
Tokens :
55D
HEM
token
$00-
$7F
GO TO
- $5F
GOSUB
- $5C
THEN
In -
- $24
LIST
- $74
LIST
- $75
STR
CON -
- $28
REM
- $5D
EOL
- $01
negat ive
ASCII
I $01
end-of-line '
token
(tokens used by RENUMBER)
Distributed under the Creative Commons License on page 5
Page 0179 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 11
RENUMBER - THEORY OF OPERATION
Because of the rigid internal representation of APPLE-II BASIC
programs (insured by the translator syntax check) writing a renumber
program was a somewhat easier task than it would have been on many
small BASIC'S. Fortunately all constants in APPLE-II BASIC (in-
eluding line number references) are preconverted to binary.
The normal renumber subroutine entry point is RENUM ($308).
The RENX entry ($300) conveniently sets the renumber range for the
user such that the entire program will be renumbered. RENUM exten-
sively uses SWEET16, the code-saving 16-bit interpretive machine
built into the APPLE-II. i Occasional 6502 code is interspersed
throughout RENUM for even greater code efficiency.
RENUM scans the entire program from beginning to end twice.
During pass 1 a line number table is built containing all line
numbers of the program found to be within the renumber range.
This table begins at the address specified by the BASIC variable
pointer, PV , and is limited in length by the program pointer, PP.
Each entry is two bytes long. A memory full error occurs if not
enough free memory is available for the table.
Byte M agazi ne , Nov. 1977, pp.
Distributed under the Creative Commons License on page 5
Page 0180 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 12
As line numbers are entered in the table corresponding new
line numbers are generated and both- new and old are displayed.
Should the new line numbers result in an 'out of ascending sequence'
condition, then a range error occurs and renumbering is terminated.
It is assumed that the line numbers of the original program are in
ascending sequence.
The purpose of pass 2 is to scan the entire BASIC program while
updating all references of line numbers found in the table to new
assignments. Aside from the line numbers themselves, the line number
references sought are identified as constants immediately preceeded
by one of the following tokens:
GOTO
GOSUB
THEN Ino
LIST
LIST
No other statement normally permitted within an APPLE-II BASIC
program may contain a line number reference. No errors will occur
during pass 2.
Exceptions such as empty line number table and null program
are properly considered by both passes of RENUM .
Distributed under the Creative Commons License on page 5
Page 0181 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
APPEND - THEORY OF OPERATION
page 13
When APPEND is called, the user program with larger line numbers
will be in memory and the one with smaller line numbers will be read
off tape. The current program resides between two pointers, PP and
HIMEM. HIMEM is preserved and set to the value contained in PP.
This 'hides' the original program and prepares to load a new one
immediately above it in memory.
The BASIC load subroutine is called and a normal memory full
error condition will result if not enough free memory is available
to contain both programs. If this error occurs then the original
program will still be hidden. Fortunately, it can be recovered by
calling the tail end of APPEND at $3CD which simply restores HIMEM.
If the load is successful then HIMEM is restored to its original value
and both programs will be joined. No line number overlap check is
performed .
Original Program
After Load
PP
PP-
HIMEM-
Prog n2
Prog #1
Prog #2
( hi dden )
HIMEM Restored
PP
Prog #1
Prog #2
HIMEM-
HIMEM
Distributed under the Creative Commons License on page 5
Page 0182 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 14
RENUMBER EXAMPLE
Renumber lines 100-110
Original to start at 150
spaced by 10
>LI3T
2, 150 MOD 256
1 G0T9 100 \
2 G0S-J3 103 >?OKS
3, 150 / 256
3 IF TH'J£ TH£iM 107
H LI ST 109,110 >?OKE
i\, 10 MOD 256
1 00 REM
103 REM
5> 10 / 256
107 REK
109 REM >P0K£
6> 100 MOD 256
1 1 REK
200 FOR 1=1 TO 10 >POK£
1, 100 / 256
210 PRINT I
2 20 :vJEXT I >POKE
%, 110 MOD 256
230 GOTO 1
>POKE
9, 110/ 256
>CALL
776
100->I 50
103->160
107->
170
109->
1 80
I 1 0-> 1 90
>LIST
1
GOTO 150
2
G0SU3 160
3
IF TRUE THEN 170
4
LIST 180,190
150
REM
160
REM
170
REK
180
REM
1 90
REM
200
FOR 1=1 TO 10
2 10
PRINT I
220
WE XT 1
230
GOTO 1
Distributed under the Creative Commons License on page 5
1 Page 0183 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 15
RENUMBER EXAMPLE (cont)
Renumber lines 100-110 to start at
10 spaced by 5
> F(J Ki ^ J I U
M n n p 5 ft
> y u n.c J J I u
/ & J o
>POK£ 4, 5
MOD 256
> ? 5 > o
/ P =^ A
/ ^ 3 O
>oALL (OS
I-> I
2-> 15
3->20
4->25
150->30
150->35
1 70->40
lS0->45
1 90->50
200- >55
21 0->60
220->65
230->70
>L1ST
10 GOTO
30
15 Gosua
35
20 IF TR'Jc THEM 40
25 LIST
45^50
3 HEK
35 P.EK
4 ^EM
45 REM
5 ^.EM
5 5 FO:^. I
=1 TO 10
60 PRINT
I
6 5 NEXT
I
70 GOTO
1
Distributed under the Creative Commons License on page 5 | Page 01 84 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
page 16
>LIST
100
200
REM
THE ORIGINAL PROGRAM
300
?.EM
>CALL
956
>LIST
1
HEM
20
^EM
THIS PROGRAM CAKE FROM
30
:^EM
1 00
REM
200
REM
THE ORIGINAL PROGRAM
300
REM
Distributed under the Creative Commons License on page 5
Page 0185 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
APPLE-II BASIC REN'JKaEH/APPiND SUSROUTINES
9i53 A.M., 11/21/1977 °AGEt I
-HENUMBER/APP'EMD S'jaROUTINES'
t
TITLE 'APPL£-II 3ASIC
2
3
4
APPLE- 11 BASIC
5
HSNUK3ES AND APPEMD
*
6
*
SU830UT INES
7
*
8
«
RENUMBER
*
9
*
NEW INITIAL (2,3)
*
1
♦
NEW INCR (4,5)
*
1 1
*
HAN3E 3EG (6,7)
♦
12
*
P.AN3E END (3,9)
13
*
*
14
USE HENX ENTRY
♦
15
*
FOR RENUMBER ALL
•
16
*
*
17
*
VOZ 11/16/7 7
*
1 3
*
APPLE COMPUTER INC.
19
*
♦
20
21
PAGE
Distributed under the Creative Commons License on page 5
Page 0186 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
6502 EQUATES
9j53 A.m.., 1 1/21/1977
22
S'J3TTL
6502 EQUATES
23
EPZ
SO
LOV-ORDER Syi6 "^0 BYTE
24
HOH
EPZ
s t
HI -ORDER.
25
Rl iL
EPZ
S 16
LOV-ORDER SWI6 Rll 3fX
26
HI IH
EPZ
$ 17
HI-ORDER.
27
H I,M£M
EPZ
S4C
BASIC HIMEM POINTER.
28
PPL
EPZ
$CA
BASIC PROG PQI.MTER.
29
P7L
EPZ
sec
3ASIC VAR POINTER.
30
MEMFULL
EQU
SE36a
BASIC MEM FULL ERROR.
31
P P.DEC
EQ'J
SE5 13
3ASIC DECIMAL PRIMT SI
32
PJWGEHR
EQU
$EE6S
BASIC RANGE ERROR.
33
LOAD
EQU
JFODF
BASIC LOAD S'J3R.
34
S7I6
EQU
$F639
SWEET I 6 ENTRY.
35
CP.OUT
EQU
$FD3E
CAR RET SU3R.
36
COUT
EQU
SFDED
CHAR OUT SUSR.
37
PAGE
Distributed under the Creative Commons License on page 5
Page 0187 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
SVEET16 ETJATES
9i53 A.M., 11/21/1977 PAGEf 3
38
SUBTTL
SWEET 1 6
EQUATES
39
ACC
EPZ
SO
SVEET16 ACCUMULATOR.
40
NEVLOV
EPZ
S 1
NEW IMITIAL LMO.
41
fJEVINCR
EPZ
S2
NE'i LNO I NCR.
42
LNLOV
EPZ
S3
LOV LMO OF REMUM RANGS
43
EPZ
S4
HI LNO OF RENUM RA^JGE.
44
TaLSTRT
EPZ
ss
LNO TABLE START.
45
T3LNDX1
EPZ
S6
PASS I LMO TBL IMDSr.
46
T3L1M
EPZ
$7
LNO TABLE LIMIT.
47
SC=^8
EPZ
S8
SCRATCH REG.
48
HKSM
EPZ
%8
HIMEM (E?)D OF PRGM).
49
SCR9
EPZ
S9
SCRATCH REG.
50
EPZ
S9
PASS 1 PROG INDEX.
5 1
EPZ
SA
ALSO PROG INDEX.
52
NEVLN
EPZ
S3
NEXT 'NEV LNO' .
53
NEVLN 1
EPZ
sc
PRIOR 'NEW LNO* ASSIGl
54
TBLND
EPZ
S6
PASS 2 LNO TABLE E.VO.
55
PaGNDX2
EPZ
$7
PASS 2 PROG INDEX.
56
CHRO
EPZ
S9
ASCII '0'.
57
CHRA
EPZ
SA
ASCII *A*.
58
MODE
EPZ
SO
CONST/LNO MODE.
59
T3LNDX2
EPZ
SB
LNO TBL IDX FOR UPDATE
60
OLDLN
EPZ
SO
OLD LNO FOR UPDATE.
61
STRCON
EPZ
S9
BASIC STR CON TOKEff.
62
REM
EPZ
SC
BASIC REM TOKEff.
63
HI3
EPZ
SO
SWEET 16 REG 13 CCPR Rl
64
THEM
EPZ
so
BASIC THEN TOKEN.
65
LIST
EPZ
so
BASIC LIST TOXEH.
66
SCRC
EPZ
sc
SCRATCH REG FOR APPENB
67
PAGE
Distributed under the Creative Commons License on page 5
Page 0188 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
APPLE-II BASIC RE.VUM3ER SaBROUTINE - PASS I
9j53 A.m., 11/21/1977 PAGEr 4
^U 1 1 irf
APPLE-lI BASIC RENUMBER SUBROUTINE - PASS 1
A
U AU
« ^ Art
UJUU 1
on
T O
f u
t C D
CTJ 1 A
nrt
Y t
f I
Cf 1 Q
f%\jU
O A •
■7 o
b r
UN U\J w
^CT t M! ft V«0 •
^ A
J4
/ J
ST
1 Kill T
OJQO >
PA
r ^
1 MU f
LNn t
rt 1 n T •
030 7 t
00
Ml PI
fl o
r O
7A
ICO
uJvo I
1 o
u u
7 7
ou r(o > n i Pi£*n
e\ 1 AC •
U J Uc. 1
7fl
f 5U rt3
OJuf 1
70
f y
CT
nncrt
1 u n r«& n •
A ^ 1 n •
U J 1 U •
1 O
1 y
uc*
uu
DC- 1
oOny > PVL.*«
n^i 1 ^ •
U J 1 o 1
r o
fl 1
OA on
oAolU VMft P 1 M 1 LI
'X
flp
C T
TaLST FIT
Tftl AMD TRf MOYt »
Al 1 ft •
OO
o o
CT
A1 t A t
9 i
o **
Mptjrt AU
N£.y UU W
PA OV MPWf Alf /TMfTTAT ^
UU PT NCiwUUW \ X X 1 I HU ^
U J 1 f 1
OD
C T
NC.WUN
1 U NIL WUN •
A*) 19*
J I O s
TP
5T
N£VLN I
U J 1 7 1
oy
ft 7
PU Pil
■ c p o n
Q A C T P DO A f3 OTP
OHO i u KnUa Pin
U J i n 1
J /
flfl
5T
Tou I n
TA Tnt TM
1 11 1 ou i n
U J i a S
1 a
J T
flO
ST
P rlG N U A
ANU PrtoJMUA*
A1 1 •
on
in*
nfl
o t
y 1
r» rt o
Prt
t P OOOMnV % 9 UMPM
A1 1 C •
OJ 1 b t
U J
A.
**o
y c
or*
O A C C 9
TUPM HAMP 0ACC 1 -
A'^ O A •
J A
y J
C T
OOP kT rw 1
PrtuN Ua I
A "1 O 1 •
U J <: I f
OA
do
y H
I n
Tat Ki n V 1
A'>0^ •
Oft
yo
T M Q
AP P
AU u
TP < P nvTP^ At7Atl TM
Uoc J 1
U 1
OA
y o
v/ Krl
T Of f M
1 OU i n
U J 9
n 1
^ ft
Q 7
y /
tap
MP on
Uo C9 X
y o
T n
A oDi^ M nv 1
WPrtbiv*JA I
A*? 9 T •
U J & f s
y y
n n
r.TU iM iJA
AHTI T PM RVTF Tft
1 uu
CT
o I
Prttj nua
ptsn/; TMnPV-
P.TUU llwi/CiA*
A-^ O A ,
OH
i U 1
f nn
A OOP K3 nv 1
1 T MP MTTMRPP^
AT '3 A •
LI J
1 Uc
DO
uPn.
1 KI1 ntt
UnUU W
TP < f MT nu THPM
U V £ O 1
1 U >J
onr u
SIB
uu lU I .J*
AT on t
1 u*«
U r ri
1 MU T
UNrtl
I p > 1 mh t them
UO I
no
Ufi
1 ns
I UO
D 1 A
nx\ Tn P 1 C •
UV » U r 1 W •
UO O U a
w 1
o u
1 HA
1 Uu
OM 7
o ♦ P
U J O b I
f 9
in?
1 U f
P 1 A
^ T
• Ta ! M nv 1
V J O U*>l iJA 1
ADD TO 1 Mn TABLE.
1 OR
QTM
1 Iw
UO O ^ i
n t
U 1
1 no
1 u ~
rvun
AS ftp CftD£
fin
u u
• i u
rkUii«
UO O Q ■
I n
• o
1 1 1
III
u o n
pnnpp
PRTMT DID LMO •->♦ ME»
vO o o »
AQ
AD
lib
LDA
#SAO
(R0,R1 1 > IM DECIMAL.
033DJ
30
ED
FD
113
JSH
COUT
03401
A9
3E
1 14
LDA
#S3£
03421
20
EO
f D
1 IS
JSR
COUT
03451
A5
I 7
1 16
LDA
Rl IH
03471
A6
16
117
LDX
Rl IL
0349t
20
13
£5
t 18
JSR
PRDEC
034CI
20
8E
FD
119
JSR
CHOUT
034rj
20
8C
F6
120
JSR
♦** END 6502 CODE «*♦
0352t
2B
121
LD
Distributed under the Creative Commons License on page 5
Page 0189 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
APPLE -11 BASIC
RENUMBER SUBROUTINE
- PASS I
o ■ c ^
9 1 3 J
A« M •
s 11/2I/J977
PAGEt 5
035 J t
3C
1 22
ST
NEVLN 1
COPY NEVLN TO NEVLN 1
0354 S
A2
1 23
ADD
NEWIMCR
AND I NCR MEVLN BY
0355 t
3B
1 24
ST
NEVLM
NEWINCR.
0356 t
OD
1 25
NUL
(VILL SKIP NEXT INST>.
035 7 t
1
126 P19
■ CPR
NEVLOW
IT LOW LNO < WE7L0V
035 8 1
02
ca
127
BHC
PASS 1
THEN RANGE ERR.
035 A t
00
128 RERR
RTN
PRINT 'RANGE ERR' KSS
035Bt
AC
6S EE
1 29
JMP
fUMGERH
AND RETURN.
035Et
00
130 MERR
RTN
PRINT 'MEM FULL,' MSG
035FI
40
63 £3
131
JMP
MEKFULL,
AND RETURN.
0362t
EC
132 PIC
INR
NEVLMl
IF HI LNO <■ MOST RECf
036 31
DC
133
CPR
NEVLMl
NEVLN THEN RANGE ERR
0364»
02
1 34
BNC
RERH
135
PAGE
Distributed under the Creative Commons License on page 5
Page 0190 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
APPLE-II 3ASIC REMUMBER SUBROUTINE - PASS 2
9i53 A.M., 11/21/1977 PAGEt 6
136 SUaiTL APPLE-II BASIC RENUMBER SU3R0UTINE - PASS 2
0366t
19
30
00
137
PASS2
SET
CHRO, X80
ASCII •0'
03591
lA
CI
00
138
SET
CHHA/SCI
ASCII 'A'
036Ct
27
139
P2A
LD
PRGN0X2
036D»
08
140
CPR
HMEM
IF PROG INDEX * HIMEM
036Et
03
63
141
BC
DOME
THEN DONE PASS 2.
0370:
E7
142
INR
PRGMDxa
SKIP LEN BYTE.
0371 1
67
143
LDD
•PRGNDX2
LINE NUMBER*
03 72t
3D
144
UPDATE
ST
OLOLN
SAVE OLD LNO«
03731
25
145
LO
TBLSTRT
0374»
38
146
ST
TBLNDXa
INIT LNO TABLE INDEX.
03 75*
21
147
LD
NEWLOW
INIT NEVLNl TO NEWLOW.
03 761
IC
00
00
148
SET
(WILL SKIP NEXT 2 INSt
149
ORG
*-2
03771
2C
ISO
uoa
1,0
WEVLM 1
03781
AS
151
ADD
NEWINCR
ADO INCR TO NEWLNI.
03791
3C
152
ST
NEWLM 1
037At
28
153
LD
TBLN0X2
IF LNO TSL IDX ■ TBLND
03 731
B6
154
SUB
TBLNO
THEM DONE SCANNING
03 7C»
03
07
155
ac
UD3
UJO TABLE.
03 7EI
6B
156
LDD
tTBLNDXa
NEXT LNO FROM LNO TASK
03 7FI
BO
157
SUB
OLOLN
LOOP TO t)D2 IF NOT SAH
0380t
07
F5
IS8
BUZ
'JD2
AS OLDLN.
0332t
C7
159
POPD
•PRGNDX2
REPLACE OLD LNO WITH
0383 t
2C
160
LD
NEVLN t
CORRESPONDING NEW LS
0384 t
77
16 1
STD
•PRGNDXa
0385 t
IB
28
00
162
UD3
SET
STRCON, $28
STR CON TOKEN.
03SSt
IC
00
00
163
SET
MODE,
(SKIPS NEXT 2 INSTR'S*
164
ORG
♦-a
03891
67
165
GOTCON
LDD
•PRGNDX2
03SAI
FC
166
OCR
MODE
IF MODE » THEN UPDAff
038Bi
08
CS
167
BMI
UPDATE
LNO REF.
038Dt
47
168
ITEM
LD
tPRGNDXa
BASIC ITEM.
03BEI
09
169
CPR
CHRO
038ri
02
09
170
BNC
CHKTOK
CHECK TOKEN FOR SPEC 11
0391 1
DA
171
CPH
CHRA
IF >■ '0' AND * 'A* TH
03921
02
F5
172
SNC
GOTCON
SKIP CONST OR UPDATi
03941
F7
173
SKPASC
OCR
PRGNDX2
03951
67
1 74
LDD
tPRGNDxa
SKIP ALL NEG BYTES OF
0396 t
05
FC
175
BN
SKPASC
STR CON, REN, OR NAl
03981
F7
176
DCR
PRGNDX2
0399t
47
177
LD
•PRGNDXa
039At
OB
I 73
CHKTOK
CPR
STRCOM
STR CON TOKEN?
039B»
06
F7
I 79
BZ
SKPASC
YES, SKIP SUBSEQUENI
039DI
IC
SO
00
180
SET
REM, $50
03A0t
DC
181
CPR
REM
REM TOKEN?
03A1 >
06
Fl
182
BZ .
SKPASC
YES, SKIP SUaSEQUENt
03A3t
08
13
183
BMt
CONTST
QOSUB, LOOK FOR LMO.
03A5I
FO
184
OCR
RI3
03A6I
FD
185
DCR
R13
(TOKEN $5F IS GOTO)
03A7I
06
OF
186
BZ
CONTST
THEM LNO, LOOK FOR LMO.
03A9I
10
24
00
187
SET
THEN, $24
03ACI
00
188
CPR
THEM
03ADi
06
09
169
BZ
CON .'ST
TH-tJ LMO, LOOK FOR LNO.
Distributed under the Creative Commons License on page 5
Page 0191 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
APPLE-II BASIC RENUMBER S'JBHOUTIME - PASS 2
9»53 A.M., 11/21/1977 PAGEj 7
Q3AFt
FO
I^Q
DCR
ACC
03301
06
BA
191
3Z
P2A
EOL (TOKEN $01)7
Q3B2I
ID
74 00
193
SET
LIST, $74
0335 1
80
193
SUB
LI ST
SET MODE • IF LIST
0336 t
09
01
194
C0NTS2
OR LIST COMMA C$73, •
03331
aq
195
CONTST
sua
ACC
CLEAR MODE FOR LNO
0339t
3C
196
coNTsa
ST
MODS
UPDATE ClfECK.
033At
01
01
197
BR
ITEM
CHECK NEXT BASIC ITEM.
198
PAGE
Distributed under the Creative Commons License on page 5
Page 0192 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
APPL£-II 3ASIC APPEND SUBROUTINE
A • M • ^
I 1/2 l/J 977
PAGE: 9
A.PPLE- I ]
BASIC APPSMD
S'JBROUT INE
033C t
20
a9 F6
200 ;-.PP£'vD
J SR
SV 1 6
033F 1
1 C
4E 00
201
SET
SCRCjHIKEM*2
03C2 1
cc
202
^ W b
POPD
tSCRC
SAVE HI MEM*
38
203
ST
HMEM
1 9
CA 00
SET
SCR9j PPL
03C7 t
69
205
LDD
9SC39
SET HIMEM TO PRESERVE
03CS »
7C
b W 9
STD
• SCRC
PROGRAM*
03C9 t
00
207
RTN
03CAt
20
DF FO
208
JSR
LOAD
LOAD FROM TAPE.
03CDI
20
89 F6
209
JSR
SV16
03DOf
CC
210
POPD
• SCRC
RESTORE HIMEM TO SHOW
03DI t
28
211
LD
KMEM
BOTH PROGRAMS
03D2t
7C
212
STD
• SCRC
(OLD AND NEW).
03D3i
od
213 DONE
RTN
RETURJJ.
03D4t
60
214
RTS
********SUCCESSFUL ASSEMBLY! NO ERRORS
Distributed under the Creative Commons License on page 5
Page 0193 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
CR0S5-R£rE
f cc
-->P.-^£ND
c.:r:TOK
c:-;ao
CHP.A
'l ': £
GO . co:'J
Hi. :;m
IVEM
LIST
L,JHI
L'JLOV
L3AD
K,jDE
VLN
NEV1.0W-
OLTLN
PI A
pia
PIC
p."! A
PASS I
PASS2
FPL
P-.GN'DX
Fv'L
=10H
HOL
Rl 1 H
PA I L
P.l 3
SCRS
SCR9
SCHC
skpasc
STP.CON
SV 1 6
T31,IM
T-5U\D
IB l:, 0X1
---i..vd:''2
0000
033C
03 9A
0DO9
OOOA
0339
02S3
FDED
FDSE
03D3
0389
OOflC
0008
03 50
POOD
0004
0003
rODF
£363
035E
OOOC
0002
0003
OOOC
0001
GOOD
0332
0357
0362
036C
03 !C
0366
OOCA
£5 IB
0009
OOOA
0007
OOCC
0001
0000
0017
0016
OOOD
££68
OOOC
0503
0300
035 A
GOQB
0009
OOOC
0394
0003
F589
0007
0006
0006
0033
COOS
OOOD
PLE-11 3ASIC ?.EN;jK5EH/APr;
007 1 Oj.'a 190 0195
:ND S'J3=10UTINES
0170
0137
0138
0194
01S3
01 13
0119
0141
01 72
0077
0079
0197
0192
0073
0072
0208
0131
0097
0163
0123
0085
0036
00S4
0144
01 05
01 03
0106
0191
0127
0092
0204
01 1 I
0039
0093
139
0080
0109
0110
0116
0117
01 84
0129
0180
0134
0077
0C80
0201
01 75
0162
0070
00S8
0154
0033
01 i6
0C5 2
0187
0169
017 1
01S6
0115
0201
009 I
0193
0074
01 02
0189
0140 0203 021 1
0104
0166 0196
015 1
0121 0124
0122 0132 0133 0148 0150 0152 0160
0126 0147
0157
0113
0090 0099
0093 0101
0142 0143
0100
0159 0161 0165 0168 0173 0174 0176 0177
0185
018 1
CG78
0031
0202
0179
0178
0076
0096
C094
0153
0145
138
0087
0206
01 32
0204
02 10
0205
0212
0120 0200 0209
0107
0156
I Page
Distributed under the Creative Commons License on page 5
0194 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
CROSS RErEREMCEj A.PPL£-H BASIC a£r.;UK5ER/APPE.'4D SUBROUTINES
UD2 0377 C158
UD3 0385 0155
UPDATE 0372 167
Distributed under the Creative Commons License on page 5 I Page 01 95 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0196 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
References
03 November 2004
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 01 97 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0198 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
References
David T Craig • 03 November 2004
Here is a list of Apple Computer and Apple-II computer technical and historical
reference materials that may prove beneficial to readers of the Woz Wonderbook
who want to know more about the details behind this document and the Apple-II
computer in the late 1970' s.
These more polished references originated in publicly published Apple Computer
documents, magazine articles, and Apple-II enthusiast private materials.
David T Craig (shirlgato@cybermesa.com) has digital copies of all of these
materials. These materials may possibly be provided with DigiBarn's Woz
Wonderbook digital materials via its web site or a CD.
SYSTEM DESCRIPTION: THE APPLE-II
Steve Wozniak • BYTE Magazine • May 1977
This description of the Apple-II computer by its main designer provides a
concise description of this computer's technical features.
MICROCOMPUTER FOR USE WITH VIDEO DISPLAY
Steve Wozniak • US Patent 4,136,359 • 23 January 1979
This is Apple Computer's patent for the Apple-II computer assigned to Steve
Wozniak. Dry reading, but has some good Apple-II technical information.
Available on the US Patent Office web site http://www.uspto.gov/patft/.
APPLE-II HISTORY
Steven Weyhrich • http://apple2history.org/history/ • 1991-2003
This great web site contains a cornucopia of accurate Apple-II historical
information. If you want to learn about the origins of Apple Computer and the
Apple-I and Apple-II computers, this is the place to go. Also available on the
internet at http: //www. bli nkenli ghts . com/classi ccmp/apple2hi story . html .
SWEET-16: THE 6502 DREAM MACHINE
Steve Wozniak • BYTE Magazine • November 1977
This is Steve Wozniak's comprehensive description of his SWEET-16 16-bit byte-
code "meta microprocessor" interpreter built into the Apple-II Integer BASIC
ROM. Wozniak's Apple-II system description in BYTE May 1977 also has a short
description of SWEET-16.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0199 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
APPLE-II REFERENCE MANUAL ("RED BOOK")
Apple Computer • January 1978
This is Apple Computer's first published technical reference manual for the
Apple-II computer. It is commonly referred to as the "Red Book" because it has a
red cover. The Red Book's contents (155 pages) were based on the Woz Wonderbook
but in a more polished format, but is not as comprehensive or readable as the
later Apple-II reference manuals. A good PDF scan of the Red Book can be found
on the internet at http://bitsavers.org/pdf/apple/ along with several other
older Apple-II manuals.
APPLE-II REFERENCE MANUAL
Apple Computer • 1979 • Document # 030-0004-01
This is Apple Computer's first revision of the Apple-II Red Book. This 275 page
manual is much improved over the Red Book and tremendously improved over the Woz
Wonderbook materials. Note the Apple document number (030-0004-01) which
indicates this is a technical manual (030), is document number 4 (0004), and is
revision 1 (01) which means this is Apple's 4th published manual.
APPLE-II MINI MANUAL
Apple Computer • 1977-1978
This 68 page manual from Apple Computer appears to be the predecessor to the Red
Book from 1978. As such, I would date this manual in the 1977-1978 range. More
complete and more detailed than the Woz Wonderbook, but not as good as the Red
Book. A good PDF scan of this manual can be found on the internet at
http : //bi t savers . org/ pdf/ apple/ .
THE WOZ PAK][
Call-A. p. P . L . E . Magazine • 15 November 1979
This 138 page document contains a large number of technical documents about the
Apple-II computer courtesy of Apple Computer and Call-A. P . P . L . E . magazine. This
is better organized and more comprehensive than the Woz Wonderbook or the Red
Book, but not as good as the Apple-II Reference Manual from 1979. Contains a
detailed article on the Apple-II floating point package.
PEEKING AT CALL-A.P.P.L.E.
Call-A.P.P.L.E. Magazine • 1978 and 1979
This 2 volume set (volume 1 dated 1978 has 92 pages, volume 2 dated 1979 has 206
pages) contains lots of Apple Computer re-produced technical information and
original Call-A.P.P.L.E. magazine information. Well worth reading.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0200 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
PROGRAMMER'S AID #i:
INSTALLATION AND OPERATING MANUAL
Apple Computer • 1978 • Document # 030-0026-01
This 113 page Apple manual describes the special programming built into the
Programmer's Aid #1 ROM chip (there was never an Aid #2 chip AFAIK) . Includes
several 6502 assembly language programs by Steve Wozniak which used his SWEET-16
16-bit byte-code interpreter. Includes more polished information for the Integer
BASIC renumber and append programs described in the Woz Wonderbook.
FLOATING POINT ROUTINES FOR THE 6502
Steve Wozniak & Roy Rankin
Dr. Dobb's Journal of Computer Calisthenics & Orthodontia • August 1976
This is an article on the Apple-II floating point package pre-dating the Woz
Wonderbook. Has more details about this package than the Wonderbook. Available
on the internet at www. st rotmann .de/twi ki /bin/vi ew/APG/AsmAppleFloatingPoint .
Concerning authorship of this floating point package, web site
http://linux.monroeccc.edu/~paulrsm/dg/dg32.htm says Wozniak wrote the core
package routines (e.g. ADD) and Rankin wrote the transcendental routines (e.g.
LOG) .
DISASSEMBLER PROGRAM FOR THE 6502
Steve Wozniak & Allen Baum
Dr. Dobb's Journal of Computer Calisthenics & Orthodontia • September 1976
This is an article on the Apple-II 6502 disassembler pre-dating the Woz
Wonderbook. Available on the internet at http://users.telenet.be/kiml-
6502/kun/il4/p06.html .
THE APPLE II PLUS PERSONAL COMPUTER SYSTEM
Apple Computer • November 1981
This is Apple Computer's data sheet for the Apple-II Plus computer, the
successor to the Apple-II computer. Shows how some of the enhancement ideas
documented in the Woz Wonderbook and the Red Book were implemented by Apple.
PRELIMINARY APPLE BASIC USERS MANUAL
Apple Computer • October 1976
This 16 page manual seems to be Apple Computer's first user manual for its
Apple-II Integer BASIC programming language. The Woz Wonderbook is very lacking
in Integer BASIC information for the user. A good PDF scan of this manual can be
found on the internet at http://bitsavers.org/pdf/apple/.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0201 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
APPLE TECH NOTES
Apple Computer and the International Apple Core (lAC) • July 1982
This 500 page document contains an extensive collection of Apple Computer
technical notes from 1982 covering the Apple-II and Apple-Ill computer families.
Many Apple-II hardware, software and documentation errata details are here.
Includes articles about the Apple-II mi ni -assembler and cassette interfacing. A
treasure trove of early Apple system technical information.
APPLE-II SYSTEM MONITOR ROM LISTING
Apple Computer • 1977
For detailed information about the internal software workings of the Apple-II
computer the source listing for the Apple-II System Monitor ROM is the key.
Available in the Apple-II reference manual dated 1979 or on the internet at
http : //members . buckeye -express . com/ma rksm/6502/ .
STEVE WOZNIAK INTERVIEW: HOMEBREW TO CHAMPAGNE
Apple Orchard Magazine • Spring 1981
An early interview with Steve Wozniak in which he provides contemporary details
about Apple Computer's origins and early days.
STEVE WOZNIAK INTERVIEW: THE APPLE STORY
BYTE Magazine • December 1984
A great interview with Steve Wozniak by BYTE magazine with lots of Apple
Computer and Apple-II information. Also includes a retrospective on SWEET-16,
Wozniak's 16-bit byte-code interpreter. This is available on the internet at
http: //apple2hi story .org/museum/articles/byte8412/byte8412 . html .
STEVE WOZNIAK INTERVIEW: STEVE WOZNIAK UNBOUND
SlashDot Interview • January 2000
http://slashdot.org/interviews/00/01/07/1124211 . shtml
This 2000 interview of Steve Wozniak contains some good 24 year recollections
about Apple Computer's origins and early years.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0202 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Bill Goldberg Interview
19 April 2004
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 0203 of 021 3
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0204 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
Bill Goldberg Interview
Bruce Damer • 19 April 2004
Source :
http : //www. digi barn . com/collect ions/books/woz-wonderbook/goldberg-on -woz -won
derbook.mpB (3.3 MB file)
Transcript created by
David T Craig <shi rlgato@cybermesa . coni> -- 02 November 2004
Interviewer: Bruce Darner <bdamer@digitalspace.coni>
Interviewee: Bill Goldberg <bi llau@coastsi de . net>
Interview duration: 3:39 minutes
BACKGROUND
The "Woz Wonderbook" was a compilation of notes from Steve Wozniak's filing
cabinet that served as the first documentation and technical support manual
for the Apple II computer (before the more famous "red book" of January
1978). Bill Goldberg, longtime Apple employee, donated his copy of the
Wonderbook to the DigiBarn (thanks Bill!). At the time he was at Apple there
was only a single copy of this thick binder of photocopied notes, diagrams
and such to be found in the Apple library. Bill, being in the technical
support role and a natural pack rat, made a copy of the Wonderbook.
INTERVIEW TRANSCRIPT
BILL GOLDBERG
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
Here it's faded. This is the Woz Wonderbook. And its
disorganized but I found the copy of this in the Apple library
and immediately made some copies of it.
So this was before the Red Book?
This is what the Red Book was made from.
Oh gosh.
Actually, I've got one or two Red Books for you.
Wonderful, because the Red Book we have is on loan.
Actually, in Service Engineering we would get the leftovers of
things. People would say "we don't need any more of this". So we
had two cases of Red Books and a few of us in the department
said "Hmm, these are worth something" and we divided them up.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0205 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
BILL GOLDBERG:
BRUCE DAMER:
Wow.
So, anyway, in here you will find some of the stuff typed, a
number of different articles, but you will also find,
unfortunately the xerox did the best job it could and it has
faded over the years, but there's handwritten notes.
So Woz wrote these notes?
Uh-Hmm [yes]. Here's a listing with some hand disassembly and
his comments. Article on the disassembler.
So this is Woz's hand notes?
Well, it's hand notes, it's various articles.
Here's a disassembled disassembler.
Uh ha. But all written by hand.
Written by hand. Yup.
And let's see. Here for instance, here's an article on the
cassette system.
Ok.
We (he?) gave up on using the cassette, but this actually is his
handwritten notes on the cassette system. So ...
This is a big book. He must have sat for hours writing this
down .
You know, somebody just went through a file drawer of his notes
and put it in a binder.
Oh.
And there was only one of these in the Apple library. So ...
Wow.
Either I or one of my colleagues checked it out and made some
copies because this was going to disappear into obscurity.
This is the Woz Wonderbook?
This is what it was called on the spine.
This would have been [19] 77?
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0206 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
BILL GOLDBERG: Uhm, actually the first article on the first of this has a date
of 9/20/77 [20 September 1977]. So, but this is just a
collection of a lot of different ... this actually goes Into
explaining . . .
BRUCE DAMER: Yeah . . .
BILL GOLDBERG: Yup. The detail that, you know ... I'm sure some of this is
hideously proprietary but who will ever know.
BRUCE DAMER: Well, not at this point.
BILL GOLDBERG: Ok, so that's the Woz ...
BRUCE DAMER: Woz ...
BILL GOLDBERG: Actually, it won't hurt to write on the spine ... here take a
pen, so its in your handwriting. That was my handwriting, so
there's nothing special about that.
###
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0207 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0208 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
DOCUMENT
Credi ts
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0209 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0210 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
Credi ts
Thanks to Bill Goldberg for donating this copy of the Woz Wonderbook.
The DigiBarn Computer Museum and Curator Bruce Damer for providing it to the
education and research community.
David T Craig is to be thanked for resurrecting the Wonderbook into a modern
digital format.
And of course, thanks to Steve Wozniak for creating the Woz Wonderbook!
Steve Wozniak circa 1977 and 1981
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0211 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5
Page 0212 of 0213
The Woz Wonderbook -- 1977 -- DigiBarn Computer Museum -- Steve Wozniak, Apple Computer Inc.
The Woz Wonderbook
The End
This page is not part of the original Wonderbook
Distributed under the Creative Commons License on page 5 I Page 021 3 of 021 3